Add deprecation warning for :terminal header arguments
This commit adds a deprecation warning when the org source block header argument :terminal is set. This should give people time to adjust their settings. The settings `org-babel-tmux-terminal` org-babel-tmux-terminal-opts` take precedence over the `:terminal` argument. Since this is a backward-incompatible change, I have added a changelog..PR-add-terminal-settings
parent
00e0de3cd7
commit
9bf6b35b8a
21
README.org
21
README.org
|
@ -24,12 +24,9 @@ In your ~.emacs~ or ~.emacs.d/init.el~ file, add the following:
|
||||||
#+BEGIN_SRC elisp
|
#+BEGIN_SRC elisp
|
||||||
(require 'ob-tmux)
|
(require 'ob-tmux)
|
||||||
(setq org-babel-default-header-args:tmux
|
(setq org-babel-default-header-args:tmux
|
||||||
'((:results . "silent") ;
|
'((:results . "silent") ;
|
||||||
(:session . "default") ; The default tmux session to send code to
|
(:session . "default") ; The default tmux session to send code to
|
||||||
(:socket . nil))) ; The default tmux socket to communicate with
|
(:socket . nil))) ; The default tmux socket to communicate with
|
||||||
;; You can use "xterm" and "gnome-terminal".
|
|
||||||
;; On mac, you can use "iterm" as well.
|
|
||||||
(:terminal . "gnome-terminal")))
|
|
||||||
|
|
||||||
;; The tmux sessions are prefixed with the following string.
|
;; The tmux sessions are prefixed with the following string.
|
||||||
;; You can customize this if you like.
|
;; You can customize this if you like.
|
||||||
|
@ -39,6 +36,7 @@ In your ~.emacs~ or ~.emacs.d/init.el~ file, add the following:
|
||||||
;; You can also customize the options passed to the terminal.
|
;; You can also customize the options passed to the terminal.
|
||||||
(setq org-babel-tmux-terminal "xterm")
|
(setq org-babel-tmux-terminal "xterm")
|
||||||
(setq org-babel-tmux-terminal-opts '("-T" "ob-tmux" "-e"))
|
(setq org-babel-tmux-terminal-opts '("-T" "ob-tmux" "-e"))
|
||||||
|
; The default terminal is "gnome-terminal" with options "--".
|
||||||
|
|
||||||
;; Finally, if your tmux is not in your $PATH for whatever reason, you
|
;; Finally, if your tmux is not in your $PATH for whatever reason, you
|
||||||
;; may set the path to the tmux binary as follows:
|
;; may set the path to the tmux binary as follows:
|
||||||
|
@ -52,16 +50,17 @@ If you use =use-package=, you can also write
|
||||||
:ensure t
|
:ensure t
|
||||||
:custom
|
:custom
|
||||||
(org-babel-default-header-args:tmux
|
(org-babel-default-header-args:tmux
|
||||||
'((:results . "silent") ;
|
'((:results . "silent") ;
|
||||||
(:session . "default") ; The default tmux session to send code to
|
(:session . "default") ; The default tmux session to send code to
|
||||||
(:socket . nil))) ; The default tmux socket to communicate with
|
(:socket . nil))) ; The default tmux socket to communicate with
|
||||||
;; The tmux sessions are prefixed with the following string.
|
;; The tmux sessions are prefixed with the following string.
|
||||||
;; You can customize this if you like.
|
;; You can customize this if you like.
|
||||||
(org-babel-tmux-session-prefix "ob-")
|
(org-babel-tmux-session-prefix "ob-")
|
||||||
;; The terminal that will be used.
|
;; The terminal that will be used.
|
||||||
;; You can also customize the options passed to the terminal.
|
;; You can also customize the options passed to the terminal.
|
||||||
(setq org-babel-tmux-terminal "xterm")
|
;; The default terminal is "gnome-terminal" with options "--".
|
||||||
(setq org-babel-tmux-terminal-opts '("-T" "ob-tmux" "-e"))
|
(org-babel-tmux-terminal "xterm")
|
||||||
|
(org-babel-tmux-terminal-opts '("-T" "ob-tmux" "-e"))
|
||||||
;; Finally, if your tmux is not in your $PATH for whatever reason, you
|
;; Finally, if your tmux is not in your $PATH for whatever reason, you
|
||||||
;; may set the path to the tmux binary as follows:
|
;; may set the path to the tmux binary as follows:
|
||||||
(org-babel-tmux-location "/usr/bin/tmux"))
|
(org-babel-tmux-location "/usr/bin/tmux"))
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Fixed
|
||||||
|
- Fix issue with lines containing leading minus signs "-". (Thanks to
|
||||||
|
medranocalvo!)
|
||||||
|
- Fix issue with lines containing trailing semicolon ";".
|
||||||
|
### Changed
|
||||||
|
- License language
|
||||||
|
### Deprecated
|
||||||
|
- Possibility to configure terminal using org-babel header arguments.
|
||||||
|
### Added
|
||||||
|
- Add installation instructions for MELPA.
|
||||||
|
- Add possibility to configure terminal and add options to the
|
||||||
|
terminal. (Thanks to dkrm0!)
|
||||||
|
|
||||||
|
## [0.1.5] - 2018-07-19
|
||||||
|
### Changed
|
||||||
|
- Make variables defcustom
|
||||||
|
- Rename internal functions
|
||||||
|
|
||||||
|
## [0.1.1] - 2018-07-17
|
||||||
|
### Added
|
||||||
|
- Initial release
|
||||||
|
|
||||||
|
[Unreleased]: https://github.com/ahendriksen/ob-tmux/compare/0.1.5...HEAD
|
||||||
|
[0.1.5]: https://github.com/ahendriksen/ob-tmux/compare/0.1.1...0.1.5
|
||||||
|
[0.1.1]: https://github.com/ahendriksen/ob-tmux/tree/0.1.1
|
65
ob-tmux.el
65
ob-tmux.el
|
@ -91,7 +91,8 @@ Argument PARAMS the org parameters of the code block."
|
||||||
(message "Sending source code block to interactive terminal session...")
|
(message "Sending source code block to interactive terminal session...")
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(let* ((org-session (cdr (assq :session params)))
|
(let* ((org-session (cdr (assq :session params)))
|
||||||
(terminal org-babel-tmux-terminal)
|
(org-header-terminal (cdr (assq :terminal params)))
|
||||||
|
(terminal (or org-header-terminal org-babel-tmux-terminal))
|
||||||
(socket (cdr (assq :socket params)))
|
(socket (cdr (assq :socket params)))
|
||||||
(socket (when socket (expand-file-name socket)))
|
(socket (when socket (expand-file-name socket)))
|
||||||
(ob-session (ob-tmux--from-org-session org-session socket))
|
(ob-session (ob-tmux--from-org-session org-session socket))
|
||||||
|
@ -108,8 +109,12 @@ Argument PARAMS the org parameters of the code block."
|
||||||
;; Disable window renaming from within tmux
|
;; Disable window renaming from within tmux
|
||||||
(ob-tmux--disable-renaming ob-session)
|
(ob-tmux--disable-renaming ob-session)
|
||||||
(ob-tmux--send-body
|
(ob-tmux--send-body
|
||||||
ob-session (org-babel-expand-body:generic body params)))))
|
ob-session (org-babel-expand-body:generic body params))
|
||||||
|
;; Warn that setting the terminal from the org source block
|
||||||
|
;; header arguments is going to be deprecated.
|
||||||
|
(message "ob-tmux terminal: %s" org-header-terminal)
|
||||||
|
(when org-header-terminal
|
||||||
|
(ob-tmux--deprecation-warning org-header-terminal)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ob-tmux object
|
;; ob-tmux object
|
||||||
|
@ -195,15 +200,15 @@ automatically space separated."
|
||||||
|
|
||||||
Argument OB-SESSION: the current ob-tmux session."
|
Argument OB-SESSION: the current ob-tmux session."
|
||||||
(let ((start-process-mandatory-args `("org-babel: terminal"
|
(let ((start-process-mandatory-args `("org-babel: terminal"
|
||||||
"*Messages*"
|
"*Messages*"
|
||||||
,terminal))
|
,terminal))
|
||||||
(tmux-cmd `(,org-babel-tmux-location
|
(tmux-cmd `(,org-babel-tmux-location
|
||||||
"attach-session"
|
"attach-session"
|
||||||
"-t" ,(ob-tmux--target ob-session))))
|
"-t" ,(ob-tmux--target ob-session))))
|
||||||
(unless (ob-tmux--socket ob-session)
|
(unless (ob-tmux--socket ob-session)
|
||||||
(apply 'start-process (append start-process-mandatory-args
|
(apply 'start-process (append start-process-mandatory-args
|
||||||
org-babel-tmux-terminal-opts
|
org-babel-tmux-terminal-opts
|
||||||
tmux-cmd)))))
|
tmux-cmd)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Tmux interaction
|
;; Tmux interaction
|
||||||
|
@ -319,6 +324,42 @@ If no window is specified in OB-SESSION, returns 't."
|
||||||
't))))
|
't))))
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Warnings
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
(defun ob-tmux--deprecation-warning (org-header-terminal)
|
||||||
|
(let* ((message (format "DEPRECATION WARNING: Setting `:terminal` using org source block header arguments is deprecated.
|
||||||
|
|
||||||
|
Consider changing your ob-tmux configuration as follows:
|
||||||
|
|
||||||
|
(setq org-babel-default-header-args:tmux
|
||||||
|
'((:results . \"\")
|
||||||
|
(:session . \"\")
|
||||||
|
(:terminal. \"%s\") ; <--- REMOVE THIS LINE
|
||||||
|
(:socket . nil)))
|
||||||
|
|
||||||
|
;; You can now customize the terminal and its options as follows:
|
||||||
|
(setq org-babel-tmux-terminal \"%s\")
|
||||||
|
(setq org-babel-tmux-terminal-opts '(\"-T\" \"ob-tmux\" \"-e\"))
|
||||||
|
; The default terminal is \"gnome-terminal\" with options \"--\".
|
||||||
|
|
||||||
|
If you have any source blocks containing `:terminal`, please consider removing them:
|
||||||
|
|
||||||
|
#+begin_src tmux :session test :terminal %s
|
||||||
|
echo hello
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
Becomes:
|
||||||
|
|
||||||
|
#+begin_src tmux :session test
|
||||||
|
echo hello
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
End of warning. (See *Warnings* buffer for full message)
|
||||||
|
" org-header-terminal org-header-terminal org-header-terminal)))
|
||||||
|
(display-warning 'deprecation-warning message :warning)
|
||||||
|
message))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Test functions
|
;; Test functions
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
Loading…
Reference in New Issue