tvl-depot/init/term-setup.el
Vincent Ambo 4fe8d78dbb refactor: Begin moving package configuration to use-package
This is the first in a series of commits for refactoring my
configuration to make use of jwiegley's use-package.

In the previous layout of the configuration there were some questions
around what settings go into which file, but in the end it is all just
related to which packages are being configured (besides settings
related to global Emacs behaviour).

This commit introduces use-package forms for all currently used
packages (which are still installed via Nix, not via package.el) but
does not yet clean up the rest of the configuration in a suitable way.

Note that this version introduces a bug in which the configuration of
telephone line is not correctly initialised after package setup.
2019-02-10 21:43:54 +01:00

32 lines
1.1 KiB
EmacsLisp

;; Utilities for term-mode
(defun open-or-create-term-buffer (buffer-name)
"Switch to the buffer with BUFFER-NAME or create a
new (multi-)term-mode buffer."
(let ((buffer (get-buffer buffer-name)))
(if (not buffer)
(multi-term)
(switch-to-buffer buffer))))
(defun counsel-switch-to-term ()
"Switch to a (multi-)term buffer or create one."
(interactive)
(let ((terms (counsel-list-buffers-with-mode 'term-mode)))
(if terms
(ivy-read "Switch to term buffer: "
(cons "New terminal" terms)
:caller 'counsel-switch-to-term
:require-match t
:action #'open-or-create-term-buffer)
(multi-term))))
(defun term-rename ()
"Rename the current terminal buffer."
(interactive)
(let* ((buffer (get-buffer (buffer-name)))
(mode (buffer-local-value 'major-mode buffer)))
(if (equal 'term-mode mode)
(rename-buffer (format "*terminal<%s>*" (read-string "New terminal name: ")))
(error "This function is only intended to rename terminal buffers."))))
(provide 'term-setup)