From 8b560b69f4c69586242936cde70c28d69e96a96d Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 21 Nov 2018 13:12:45 +0100 Subject: [PATCH] [Cleanup] Move eshell-C-d inside the eshell configuration block --- configuration.org | 52 +++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/configuration.org b/configuration.org index 1196d2f..749c89a 100644 --- a/configuration.org +++ b/configuration.org @@ -736,26 +736,6 @@ to the beginning of the file." (open-line-above))) #+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 *** Get specific fields from a record in ~idm~ @@ -1210,14 +1190,38 @@ Because I’m a sysadmin, too. ** ~eshell~ +This is a function to delete a character, or close ~eshell~ if there’s 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 (use-package eshell - :config - (add-hook 'eshell-mode-hook - (lambda () (local-set-key (kbd "C-d") #'eshell-C-d))) :bind (:map gpolonkai/pers-map - ("e" . eshell))) + ("e" . eshell)) + :hook + (eshell-mode . gpolonkai/eshell-set-c-d-locally)) #+END_SRC ** ~saveplace~