From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Branham Newsgroups: gmane.emacs.bugs Subject: bug#22792: eshell-mode-map declaration Date: Fri, 28 Jun 2019 13:14:20 -0500 Message-ID: <87woh5mvb7.fsf@gmail.com> References: <56CDC6D3.1050106@boccaperta.com> <877e976nhx.fsf@gmail.com> <85pnmy6deq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="199311"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.2.0; emacs 27.0.50 Cc: control@debbugs.gnu.org, 22792@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jun 28 20:25:47 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hgvZB-000pjR-Oh for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Jun 2019 20:25:46 +0200 Original-Received: from localhost ([::1]:35256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvZA-0004TA-Ou for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Jun 2019 14:25:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34262) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvOu-0007gX-UX for bug-gnu-emacs@gnu.org; Fri, 28 Jun 2019 14:15:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvOr-0007qW-Bh for bug-gnu-emacs@gnu.org; Fri, 28 Jun 2019 14:15:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57634) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hgvOo-0007ng-T5 for bug-gnu-emacs@gnu.org; Fri, 28 Jun 2019 14:15:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hgvOo-0000hI-Ij for bug-gnu-emacs@gnu.org; Fri, 28 Jun 2019 14:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Branham Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Jun 2019 18:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22792 X-GNU-PR-Package: emacs Original-Received: via spool by 22792-submit@debbugs.gnu.org id=B22792.15617456752597 (code B ref 22792); Fri, 28 Jun 2019 18:15:02 +0000 Original-Received: (at 22792) by debbugs.gnu.org; 28 Jun 2019 18:14:35 +0000 Original-Received: from localhost ([127.0.0.1]:42945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgvOM-0000fi-3F for submit@debbugs.gnu.org; Fri, 28 Jun 2019 14:14:35 -0400 Original-Received: from mail-ot1-f42.google.com ([209.85.210.42]:45870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hgvOH-0000fK-1d; Fri, 28 Jun 2019 14:14:30 -0400 Original-Received: by mail-ot1-f42.google.com with SMTP id x21so6860607otq.12; Fri, 28 Jun 2019 11:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=Wn9y/fLy2tgarmmLwukz7hgZDTYI1cr6dLWddMq3Tn0=; b=FZ2Y4efKIFkulA2NMcp+oC1qwQacZ9soGb0M3j5YLqX13qbiWQIr5lRbVfrljhTHsV rZHnLK9nNzVdepRMG0k8SOgxMeeE4kxcRDSTYAPla4Nz9zB6SDQ/pL8NweVn2xbDC6ss lBCQdQ0uP6lI5XKgJaSsDPEoF0svJ78aH7CdOnfLaxE02wKKoUreFB8Aly6+sUs7XuKR ouK2orX5FrPssKRWkGaLJXCyOZmHpEFO7qzfwUpe5z0PJHv5YmXsS6843EhHFmsBWvmd C740f/1rOy/8g/9wxCMJuQIxrxQcZW57cZ8yV0qx0uqP4XTBOrcnGBfsCzjSAs9HwC1N P6fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=Wn9y/fLy2tgarmmLwukz7hgZDTYI1cr6dLWddMq3Tn0=; b=noOBiOvEecftyKYU6VqjkNOoU/QPDRId4YZe7JznxuJN2lUQeEjd1YNroGIaRPr4BQ 3eZuNHFPsJXUBjnEjnICk1eteMLypJvn9qGts5oQuzwYjowKHRcvloGxZPzvXxbiwLaQ K8XU8IBq74SzJhJ4wuT2suEpj2pk71RScUm3nAKSDb9S5qORggp0QV4U/k0Ikh+XFlkz 7JgBx3PaWrDQic/b8gD4MEl/kcVz2iuzk3S9v9605cwD3zRkachBkurr7Wx76cgcGEJU 8cWiYy9AaAAtq1FG80C/mCBT/+s3ZhD9rgspTb06VEnAn9QnNdrZwjP8oAJZU9FQRqkS KJdg== X-Gm-Message-State: APjAAAWeHK9Xj+6awGsaS4rAitOvHgwFy/APznkxuvK7hN+YI4NcwirN Q/VLbSlv+10G/pZaKjJbw/FizXXGbDc= X-Google-Smtp-Source: APXvYqz2sSdUwf1sqRbQKOmPCDew0b9W0bmFTgMDwc6r9cNLQNh+iA3NrxzC6zhjSw009ORkiMXmqg== X-Received: by 2002:a05:6830:1042:: with SMTP id b2mr9269312otp.345.1561745662989; Fri, 28 Jun 2019 11:14:22 -0700 (PDT) Original-Received: from earth (cpe-70-114-192-208.austin.res.rr.com. [70.114.192.208]) by smtp.gmail.com with ESMTPSA id i19sm968322oib.12.2019.06.28.11.14.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 11:14:21 -0700 (PDT) In-reply-to: <85pnmy6deq.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:161750 Archived-At: --=-=-= Content-Type: text/plain tags 22792 patch quit On Thu 27 Jun 2019 at 14:23, Noam Postavsky wrote: > Alex Branham writes: > >> We could create an em-cmpl minor mode with its own keymap, I >> suppose. Would that be satisfactory? > > Makes sense to me. OK, here's a patch that does so. The general idea is to make a minor mode with its own keymap for each of eshell's modules that (previously) assigned their keybindings into eshell-mode-map. Alex --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-eshell-mode-map-initialization.patch >From 00e5ad69971e7f9abacf10d25325bdee6088f648 Mon Sep 17 00:00:00 2001 From: Alex Branham Date: Wed, 26 Jun 2019 13:59:06 -0500 Subject: [PATCH] Fix eshell-mode-map initialization * lisp/eshell/esh-mode.el (eshell-mode-map): (eshell-command-map): Set up normal keymaps and prefix commands rather than re-initializing them in each eshell buffer * lisp/eshell/em-cmpl.el (eshell-cmpl-mode-map): (eshell-cmpl-mode): (eshell-cmpl-initialize): * lisp/eshell/em-hist.el (eshell-hist-mode-map): (eshell-hist-mode): (eshell-hist-initialize): * lisp/eshell/em-pred.el (eshell-pred-mode-map): (eshell-pred-mode): (eshell-pred-initialize): * lisp/eshell/em-prompt.el (eshell-prompt-mode-map): (eshell-prompt-mode): (eshell-prompt-initialize): * lisp/eshell/em-rebind.el (eshell-rebind-mode-map): (eshell-rebind-mode): (eshell-rebind-initialize): * lisp/eshell/esh-arg.el (eshell-arg-mode-map): (eshell-arg-mode): (eshell-arg-initialize): * lisp/eshell/esh-proc.el (eshell-proc-mode-map): (eshell-proc-mode): (eshell-proc-initialize): * lisp/eshell/esh-var.el (eshell-var-mode-map): (eshell-var-mode): (eshell-var-initialize): Create a new minor mode with a keymap and call it in the module initialization function. bug#33808 bug#22792 --- etc/NEWS | 5 ++++ lisp/eshell/em-cmpl.el | 33 ++++++++++++---------- lisp/eshell/em-hist.el | 60 +++++++++++++++++++++------------------- lisp/eshell/em-pred.el | 13 +++++++-- lisp/eshell/em-prompt.el | 14 ++++++++-- lisp/eshell/em-rebind.el | 11 +++++++- lisp/eshell/esh-arg.el | 14 +++++++--- lisp/eshell/esh-mode.el | 58 +++++++++++++++++--------------------- lisp/eshell/esh-proc.el | 26 +++++++++-------- lisp/eshell/esh-var.el | 14 ++++++---- 10 files changed, 148 insertions(+), 100 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 864eb8c110..83fac26e3a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1237,6 +1237,11 @@ default, and not just the opening element. behave similarly, e.g. Pcomplete's default cycling can be obtained with '(setq completion-cycle-threshold 5)'. +*** Eshell no longer re-initializes its keymap every call. +This allows users to use (define-key eshell-mode-map ...) as usual. +Some modules have their own minor mode now to account for these +changes. + --- *** Expansion of history event designators is disabled by default. To restore the old behavior, use diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 8f6c6781b9..952091a479 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -244,6 +244,24 @@ to writing a completion function." (let ((completion-at-point-functions '(lisp-completion-at-point))) (completion-at-point))) +(defvar eshell-cmpl-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [(control ?i)] #'completion-at-point) + ;; jww (1999-10-19): Will this work on anything but X? + (define-key map [backtab] #'pcomplete-reverse) + (define-key map [(meta ??)] #'completion-help-at-point) + (define-key map [(meta control ?i)] #'eshell-complete-lisp-symbol) + ;; C-c prefix: + (define-key map (kbd "C-c M-h") #'eshell-completion-help) + (define-key map (kbd "C-c TAB") #'pcomplete-expand-and-complete) + (define-key map (kbd "C-c C-i") #'pcomplete-expand-and-complete) + (define-key map (kbd "C-c SPC") #'pcomplete-expand) + map)) + +(define-minor-mode eshell-cmpl-mode + "Minor mode that provides a keymap when `eshell-cmpl' active." + :keymap eshell-cmpl-mode-map) + (defun eshell-cmpl-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the completions module." (set (make-local-variable 'pcomplete-command-completion-function) @@ -291,22 +309,9 @@ to writing a completion function." eshell-special-chars-outside-quoting))) nil t) (add-hook 'pcomplete-quote-arg-hook #'eshell-quote-backslash nil t) - ;;(define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol) ; Redundant - (define-key eshell-mode-map [(meta control ?i)] 'eshell-complete-lisp-symbol) - (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help) - (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete) - (define-key eshell-command-map [(control ?i)] - 'pcomplete-expand-and-complete) - (define-key eshell-command-map [space] 'pcomplete-expand) - (define-key eshell-command-map [? ] 'pcomplete-expand) - ;;(define-key eshell-mode-map [tab] 'completion-at-point) ;Redundant! - (define-key eshell-mode-map [(control ?i)] 'completion-at-point) (add-hook 'completion-at-point-functions #'pcomplete-completions-at-point nil t) - ;; jww (1999-10-19): Will this work on anything but X? - (define-key eshell-mode-map - (if (featurep 'xemacs) [iso-left-tab] [backtab]) 'pcomplete-reverse) - (define-key eshell-mode-map [(meta ??)] 'completion-help-at-point)) + (eshell-cmpl-mode)) (defun eshell-completion-command-name () "Return the command name, possibly sans globbing." diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index adb028002b..19782e8d6c 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el @@ -202,6 +202,32 @@ element, regardless of any text on the command line. In that case, map) "Keymap used in isearch in Eshell.") +(defvar eshell-hist-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [up] #'eshell-previous-matching-input-from-input) + (define-key map [down] #'eshell-next-matching-input-from-input) + (define-key map [(control up)] #'eshell-previous-input) + (define-key map [(control down)] #'eshell-next-input) + (define-key map [(meta ?r)] #'eshell-previous-matching-input) + (define-key map [(meta ?s)] #'eshell-next-matching-input) + (define-key map (kbd "C-c M-r") #'eshell-previous-matching-input-from-input) + (define-key map (kbd "C-c M-s") #'eshell-next-matching-input-from-input) + ;; FIXME: Relies on `eshell-hist-match-partial' being set _before_ + ;; em-hist is loaded and won't respect changes. + (if eshell-hist-match-partial + (progn + (define-key map [(meta ?p)] 'eshell-previous-matching-input-from-input) + (define-key map [(meta ?n)] 'eshell-next-matching-input-from-input) + (define-key map (kbd "C-c M-p") #'eshell-previous-input) + (define-key map (kbd "C-c M-n") #'eshell-next-input)) + (define-key map [(meta ?p)] #'eshell-previous-input) + (define-key map [(meta ?n)] #'eshell-next-input) + (define-key map (kbd "C-c M-p") #'eshell-previous-matching-input-from-input) + (define-key map (kbd "C-c M-n") #'eshell-next-matching-input-from-input)) + (define-key map (kbd "C-c C-l") #'eshell-list-history) + (define-key map (kbd "C-c C-x") #'eshell-get-next-from-history) + map)) + (defvar eshell-rebind-keys-alist) ;;; Functions: @@ -216,6 +242,10 @@ Returns non-nil if INPUT is blank." Returns nil if INPUT is prepended by blank space, otherwise non-nil." (not (string-match-p "\\`\\s-+" input))) +(define-minor-mode eshell-hist-mode + "Minor mode for the eshell-hist module." + :keymap eshell-hist-mode-map) + (defun eshell-hist-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the history management code for one Eshell buffer." (when (eshell-using-module 'eshell-cmpl) @@ -242,30 +272,7 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil." (lambda () (setq overriding-terminal-local-map nil))) nil t)) - (define-key eshell-mode-map [up] 'eshell-previous-matching-input-from-input) - (define-key eshell-mode-map [down] 'eshell-next-matching-input-from-input) - (define-key eshell-mode-map [(control up)] 'eshell-previous-input) - (define-key eshell-mode-map [(control down)] 'eshell-next-input) - (define-key eshell-mode-map [(meta ?r)] 'eshell-previous-matching-input) - (define-key eshell-mode-map [(meta ?s)] 'eshell-next-matching-input) - (define-key eshell-command-map [(meta ?r)] - 'eshell-previous-matching-input-from-input) - (define-key eshell-command-map [(meta ?s)] - 'eshell-next-matching-input-from-input) - (if eshell-hist-match-partial - (progn - (define-key eshell-mode-map [(meta ?p)] - 'eshell-previous-matching-input-from-input) - (define-key eshell-mode-map [(meta ?n)] - 'eshell-next-matching-input-from-input) - (define-key eshell-command-map [(meta ?p)] 'eshell-previous-input) - (define-key eshell-command-map [(meta ?n)] 'eshell-next-input)) - (define-key eshell-mode-map [(meta ?p)] 'eshell-previous-input) - (define-key eshell-mode-map [(meta ?n)] 'eshell-next-input) - (define-key eshell-command-map [(meta ?p)] - 'eshell-previous-matching-input-from-input) - (define-key eshell-command-map [(meta ?n)] - 'eshell-next-matching-input-from-input))) + (eshell-hist-mode)) (make-local-variable 'eshell-history-size) (or eshell-history-size @@ -300,10 +307,7 @@ Returns nil if INPUT is prepended by blank space, otherwise non-nil." (add-hook 'kill-emacs-hook #'eshell-save-some-history) (make-local-variable 'eshell-input-filter-functions) - (add-hook 'eshell-input-filter-functions #'eshell-add-to-history nil t) - - (define-key eshell-command-map [(control ?l)] 'eshell-list-history) - (define-key eshell-command-map [(control ?x)] 'eshell-get-next-from-history)) + (add-hook 'eshell-input-filter-functions #'eshell-add-to-history nil t)) (defun eshell-save-some-history () "Save the history for any open Eshell buffers." diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el index 9bc856a296..1017e2b7c0 100644 --- a/lisp/eshell/em-pred.el +++ b/lisp/eshell/em-pred.el @@ -229,6 +229,12 @@ FOR LISTS OF ARGUMENTS: EXAMPLES: *.c(:o) sorted list of .c files") +(defvar eshell-pred-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c M-q") #'eshell-display-predicate-help) + (define-key map (kbd "C-c M-m") #'eshell-display-modifier-help) + map)) + ;;; Functions: (defun eshell-display-predicate-help () @@ -245,12 +251,15 @@ EXAMPLES: (lambda () (insert eshell-modifier-help-string))))) +(define-minor-mode eshell-pred-mode + "Minor mode for the eshell-pred module." + :keymap eshell-pred-mode-map) + (defun eshell-pred-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the predicate/modifier code." (add-hook 'eshell-parse-argument-hook #'eshell-parse-arg-modifier t t) - (define-key eshell-command-map [(meta ?q)] 'eshell-display-predicate-help) - (define-key eshell-command-map [(meta ?m)] 'eshell-display-modifier-help)) + (eshell-pred-mode)) (defun eshell-apply-modifiers (lst predicates modifiers) "Apply to LIST a series of PREDICATES and MODIFIERS." diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index adc68b6c85..9c396ce627 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -97,8 +97,18 @@ arriving, or after." :options '(eshell-show-maximum-output) :group 'eshell-prompt) +(defvar eshell-prompt-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c C-n") #'eshell-next-prompt) + (define-key map (kbd "C-c C-p") #'eshell-previous-prompt) + map)) + ;;; Functions: +(define-minor-mode eshell-prompt-mode + "Minor mode for eshell-prompt module." + :keymap eshell-prompt-mode-map) + (defun eshell-prompt-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the prompting code." (unless eshell-non-interactive-p @@ -110,9 +120,7 @@ arriving, or after." (set (make-local-variable 'eshell-skip-prompt-function) 'eshell-skip-prompt) - - (define-key eshell-command-map [(control ?n)] 'eshell-next-prompt) - (define-key eshell-command-map [(control ?p)] 'eshell-previous-prompt))) + (eshell-prompt-mode))) (defun eshell-emit-prompt () "Emit a prompt if eshell is being used interactively." diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el index a817edbcc9..318f13d244 100644 --- a/lisp/eshell/em-rebind.el +++ b/lisp/eshell/em-rebind.el @@ -137,6 +137,11 @@ This is default behavior of shells like bash." :type '(repeat function) :group 'eshell-rebind) +(defvar eshell-rebind-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c M-l") #'eshell-lock-local-map) + map)) + ;; Internal Variables: (defvar eshell-input-keymap) @@ -145,6 +150,10 @@ This is default behavior of shells like bash." ;;; Functions: +(define-minor-mode eshell-rebind-mode + "Minor mode for the eshell-rebind module." + :keymap eshell-rebind-mode-map) + (defun eshell-rebind-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the inputting code." (unless eshell-non-interactive-p @@ -154,7 +163,7 @@ This is default behavior of shells like bash." (make-local-variable 'overriding-local-map) (add-hook 'post-command-hook 'eshell-rebind-input-map nil t) (set (make-local-variable 'eshell-lock-keymap) nil) - (define-key eshell-command-map [(meta ?l)] 'eshell-lock-local-map))) + (eshell-rebind-mode))) (defun eshell-lock-local-map (&optional arg) "Lock or unlock the current local keymap. diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el index 026edc5980..bd31703e0d 100644 --- a/lisp/eshell/esh-arg.el +++ b/lisp/eshell/esh-arg.el @@ -155,14 +155,20 @@ treated as a literal character." :type 'hook :group 'eshell-arg) +(defvar eshell-arg-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c M-b") #'eshell-insert-buffer-name) + map)) + ;;; Functions: +(define-minor-mode eshell-arg-mode + "Minor mode for the arg eshell module." + :keymap eshell-arg-mode-map) + (defun eshell-arg-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the argument parsing code." - ;; This is supposedly run after enabling esh-mode, when eshell-mode-map - ;; already exists. - (defvar eshell-command-map) - (define-key eshell-command-map [(meta ?b)] 'eshell-insert-buffer-name) + (eshell-arg-mode) (set (make-local-variable 'eshell-inside-quote-regexp) nil) (set (make-local-variable 'eshell-outside-quote-regexp) nil)) diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 80844c3a64..91204877f5 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -213,10 +213,7 @@ This is used by `eshell-watch-for-password-prompt'." ;; these are only set to nil initially for the sake of the ;; byte-compiler, when compiling other files which `require' this one (defvar eshell-mode nil) -(defvar eshell-mode-map nil) (defvar eshell-command-running-string "--") -(defvar eshell-command-map nil) -(defvar eshell-command-prefix nil) (defvar eshell-last-input-start nil) (defvar eshell-last-input-end nil) (defvar eshell-last-output-start nil) @@ -286,6 +283,32 @@ This is used by `eshell-watch-for-password-prompt'." (standard-syntax-table)) st)) +(defvar eshell-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [(control ?c)] 'eshell-command-map) + (define-key map "\r" #'eshell-send-input) + (define-key map "\M-\r" #'eshell-queue-input) + (define-key map [(meta control ?l)] #'eshell-show-output) + (define-key map [(control ?a)] #'eshell-bol) + map)) + +(defvar eshell-command-map + (let ((map (define-prefix-command 'eshell-command-map))) + (define-key map [(meta ?o)] #'eshell-mark-output) + (define-key map [(meta ?d)] #'eshell-toggle-direct-send) + (define-key map [(control ?a)] #'eshell-bol) + (define-key map [(control ?b)] #'eshell-backward-argument) + (define-key map [(control ?e)] #'eshell-show-maximum-output) + (define-key map [(control ?f)] #'eshell-forward-argument) + (define-key map [(control ?m)] #'eshell-copy-old-input) + (define-key map [(control ?o)] #'eshell-kill-output) + (define-key map [(control ?r)] #'eshell-show-output) + (define-key map [(control ?t)] #'eshell-truncate-buffer) + (define-key map [(control ?u)] #'eshell-kill-input) + (define-key map [(control ?w)] #'backward-kill-word) + (define-key map [(control ?y)] #'eshell-repeat-argument) + map)) + ;;; User Functions: (defun eshell-kill-buffer-function () @@ -304,10 +327,6 @@ and the hook `eshell-exit-hook'." "Emacs shell interactive mode." (setq-local eshell-mode t) - ;; FIXME: What the hell!? - (setq-local eshell-mode-map (make-sparse-keymap)) - (use-local-map eshell-mode-map) - (when eshell-status-in-mode-line (make-local-variable 'eshell-command-running-string) (let ((fmt (copy-sequence mode-line-format))) @@ -316,31 +335,6 @@ and the hook `eshell-exit-hook'." (if mode-line-elt (setcar mode-line-elt 'eshell-command-running-string)))) - (define-key eshell-mode-map "\r" 'eshell-send-input) - (define-key eshell-mode-map "\M-\r" 'eshell-queue-input) - (define-key eshell-mode-map [(meta control ?l)] 'eshell-show-output) - (define-key eshell-mode-map [(control ?a)] 'eshell-bol) - - (setq-local eshell-command-prefix (make-symbol "eshell-command-prefix")) - (fset eshell-command-prefix (make-sparse-keymap)) - (setq-local eshell-command-map (symbol-function eshell-command-prefix)) - (define-key eshell-mode-map [(control ?c)] eshell-command-prefix) - - (define-key eshell-command-map [(meta ?o)] 'eshell-mark-output) - (define-key eshell-command-map [(meta ?d)] 'eshell-toggle-direct-send) - - (define-key eshell-command-map [(control ?a)] 'eshell-bol) - (define-key eshell-command-map [(control ?b)] 'eshell-backward-argument) - (define-key eshell-command-map [(control ?e)] 'eshell-show-maximum-output) - (define-key eshell-command-map [(control ?f)] 'eshell-forward-argument) - (define-key eshell-command-map [(control ?m)] 'eshell-copy-old-input) - (define-key eshell-command-map [(control ?o)] 'eshell-kill-output) - (define-key eshell-command-map [(control ?r)] 'eshell-show-output) - (define-key eshell-command-map [(control ?t)] 'eshell-truncate-buffer) - (define-key eshell-command-map [(control ?u)] 'eshell-kill-input) - (define-key eshell-command-map [(control ?w)] 'backward-kill-word) - (define-key eshell-command-map [(control ?y)] 'eshell-repeat-argument) - (setq local-abbrev-table eshell-mode-abbrev-table) (set (make-local-variable 'list-buffers-directory) diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 32a3eecb52..7825377e66 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -109,6 +109,16 @@ information, for example." (defvar eshell-process-list nil "A list of the current status of subprocesses.") +(defvar eshell-proc-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c M-i") #'eshell-insert-process) + (define-key map (kbd "C-c C-c") #'eshell-interrupt-process) + (define-key map (kbd "C-c C-k") #'eshell-kill-process) + (define-key map (kbd "C-c C-d") #'eshell-send-eof-to-process) + (define-key map (kbd "C-c C-s") #'list-processes) + (define-key map (kbd "C-c C-\\") #'eshell-quit-process) + map)) + ;;; Functions: (defun eshell-kill-process-function (proc status) @@ -121,20 +131,14 @@ PROC and STATUS to functions on the latter." (eshell-reset-after-proc status) (run-hook-with-args 'eshell-kill-hook proc status)) +(define-minor-mode eshell-proc-mode + "Minor mode for the proc eshell module." + :keymap eshell-proc-mode-map) + (defun eshell-proc-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the process handling code." (make-local-variable 'eshell-process-list) - ;; This is supposedly run after enabling esh-mode, when eshell-command-map - ;; already exists. - (defvar eshell-command-map) - (define-key eshell-command-map [(meta ?i)] 'eshell-insert-process) - (define-key eshell-command-map [(control ?c)] 'eshell-interrupt-process) - (define-key eshell-command-map [(control ?k)] 'eshell-kill-process) - (define-key eshell-command-map [(control ?d)] 'eshell-send-eof-to-process) -; (define-key eshell-command-map [(control ?q)] 'eshell-continue-process) - (define-key eshell-command-map [(control ?s)] 'list-processes) -; (define-key eshell-command-map [(control ?z)] 'eshell-stop-process) - (define-key eshell-command-map [(control ?\\)] 'eshell-quit-process)) + (eshell-proc-mode)) (defun eshell-reset-after-proc (status) "Reset the command input location after a process terminates. diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index b08a5d242f..00bea09384 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -197,8 +197,17 @@ function), and the arguments passed to this function would be the list (put 'eshell-variable-aliases-list 'risky-local-variable t) +(defvar eshell-var-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c M-v") #'eshell-insert-envvar) + map)) + ;;; Functions: +(define-minor-mode eshell-var-mode + "Minor mode for the esh-var module." + :keymap eshell-var-mode-map) + (defun eshell-var-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the variable handle code." ;; Break the association with our parent's environment. Otherwise, @@ -207,11 +216,6 @@ function), and the arguments passed to this function would be the list (set (make-local-variable 'process-environment) (eshell-copy-environment))) - ;; This is supposedly run after enabling esh-mode, when eshell-command-map - ;; already exists. - (defvar eshell-command-map) - (define-key eshell-command-map [(meta ?v)] 'eshell-insert-envvar) - (set (make-local-variable 'eshell-special-chars-inside-quoting) (append eshell-special-chars-inside-quoting '(?$))) (set (make-local-variable 'eshell-special-chars-outside-quoting) -- 2.22.0 --=-=-=--