[Cleanup] Move eshell-C-d inside the eshell configuration block

This commit is contained in:
Gergely Polonkai 2018-11-21 13:12:45 +01:00
parent cd733501e6
commit 8b560b69f4

View File

@ -736,26 +736,6 @@ to the beginning of the file."
(open-line-above))) (open-line-above)))
#+END_SRC #+END_SRC
** EShell related
*** Delete a character, or close ~eshell~ if nothing to delete
:PROPERTIES:
:SOURCE: https://ryuslash.org/posts/C-d-to-close-eshell.html
:END:
#+BEGIN_SRC emacs-lisp
(defun eshell-C-d ()
"Either call `delete-char' interactively or quit."
(interactive)
(condition-case err
(call-interactively #'delete-char)
(error (if (and (eq (car err) 'end-of-buffer)
(looking-back eshell-prompt-regexp nil))
(kill-buffer)
(signal (car err) (cdr err))))))
#+END_SRC
** ~idm~ (ID manager) related functions ** ~idm~ (ID manager) related functions
*** Get specific fields from a record in ~idm~ *** Get specific fields from a record in ~idm~
@ -1210,14 +1190,38 @@ Because Im a sysadmin, too.
** ~eshell~ ** ~eshell~
This is a function to delete a character, or close ~eshell~ if theres nothing to delete. Taken
from [[https://ryuslash.org/posts/C-d-to-close-eshell.html][here]].
#+BEGIN_SRC emacs-lisp
(defun eshell-C-d ()
"Either call `delete-char' interactively or quit."
(interactive)
(condition-case err
(call-interactively #'delete-char)
(error (if (and (eq (car err) 'end-of-buffer)
(looking-back eshell-prompt-regexp nil))
(kill-buffer)
(signal (car err) (cdr err))))))
#+END_SRC
Function to bind it locally to =C-d=.
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/eshell-set-c-d-locally ()
(local-set-key (kbd "C-d") #'eshell-C-d))
#+END_SRC
Now set up eshell.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package eshell (use-package eshell
:config
(add-hook 'eshell-mode-hook
(lambda () (local-set-key (kbd "C-d") #'eshell-C-d)))
:bind :bind
(:map gpolonkai/pers-map (:map gpolonkai/pers-map
("e" . eshell))) ("e" . eshell))
:hook
(eshell-mode . gpolonkai/eshell-set-c-d-locally))
#+END_SRC #+END_SRC
** ~saveplace~ ** ~saveplace~