From 292e6261be8d4b7b08f87e70eb8490e31b3e9a4f Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 20 Jul 2021 23:48:43 +0300 Subject: Add new mode context-menu-mode and use it in info.el and goto-addr.el * lisp/mouse.el (context-menu-functions): New defcustom. (context-menu-overriding-function): New function. (context-menu-filter-function): New defcustom. (context-menu-map): New function. (context-menu-undo, context-menu-region): New menu functions. (context-menu-mode): New mode. * lisp/info.el (Info-context-menu): New function. (Info-mode): Add Info-context-menu to context-menu-functions. * lisp/net/goto-addr.el (goto-address-context-menu): New function. (goto-address-at-click): New command. (goto-address-mode): Add goto-address-context-menu to context-menu-functions. --- lisp/mouse.el | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 89e5d7c48a3..580fe8eb352 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -276,6 +276,124 @@ not it is actually displayed." local-menu minor-mode-menus))) + +;; Context menus. + +(defcustom context-menu-functions '(context-menu-undo context-menu-region) + "List of functions that produce the contents of the context menu." + :type 'hook + :version "28.1") + +(defvar context-menu-overriding-function nil + "Function that can override the list produced by `context-menu-functions'.") + +(defcustom context-menu-filter-function nil + "Function that can filter the list produced by `context-menu-functions'." + :type 'function + :version "28.1") + +(defun context-menu-map () + (let ((menu (make-sparse-keymap "Context Menu"))) + (if (functionp context-menu-overriding-function) + (setq menu (funcall context-menu-overriding-function menu)) + (run-hook-wrapped 'context-menu-functions + (lambda (fun) + (setq menu (funcall fun menu)) + nil))) + (setq menu (cons (car menu) (nreverse (cdr menu)))) + (when (functionp context-menu-filter-function) + (setq menu (funcall context-menu-filter-function menu))) + menu)) + +(defun context-menu-undo (menu) + (bindings--define-key menu [undo] + '(menu-item "Undo" undo + :visible (and (not buffer-read-only) + (not (eq t buffer-undo-list)) + (if (eq last-command 'undo) + (listp pending-undo-list) + (consp buffer-undo-list))) + :help "Undo last edits")) + (bindings--define-key menu [undo-redo] + '(menu-item "Redo" undo-redo + :visible (and (not buffer-read-only) + (undo--last-change-was-undo-p buffer-undo-list)) + :help "Redo last undone edits")) + menu) + +(defun context-menu-region (menu) + (bindings--define-key menu [cut] + '(menu-item "Cut" kill-region + :visible (and mark-active (not buffer-read-only)) + :help + "Cut (kill) text in region between mark and current position")) + (bindings--define-key menu [copy] + ;; ns-win.el said: Substitute a Copy function that works better + ;; under X (for GNUstep). + `(menu-item "Copy" ,(if (featurep 'ns) + 'ns-copy-including-secondary + 'kill-ring-save) + :visible mark-active + :help "Copy text in region between mark and current position" + :keys ,(if (featurep 'ns) + "\\[ns-copy-including-secondary]" + "\\[kill-ring-save]"))) + (bindings--define-key menu [paste] + `(menu-item "Paste" mouse-yank-primary + :visible (funcall + ',(lambda () + (and (or + (gui-backend-selection-exists-p 'CLIPBOARD) + (if (featurep 'ns) ; like paste-from-menu + (cdr yank-menu) + kill-ring)) + (not buffer-read-only)))) + :help "Paste (yank) text most recently cut/copied")) + (bindings--define-key menu (if (featurep 'ns) [select-paste] + [paste-from-menu]) + ;; ns-win.el said: Change text to be more consistent with + ;; surrounding menu items `paste', etc." + `(menu-item ,(if (featurep 'ns) "Select and Paste" "Paste from Kill Menu") + yank-menu + :visible (and (cdr yank-menu) (not buffer-read-only)) + :help "Choose a string from the kill ring and paste it")) + (bindings--define-key menu [clear] + '(menu-item "Clear" delete-active-region + :visible (and mark-active + (not buffer-read-only)) + :help + "Delete the text in region between mark and current position")) + (bindings--define-key menu [mark-whole-buffer] + '(menu-item "Select All" mark-whole-buffer + :help "Mark the whole buffer for a subsequent cut/copy")) + menu) + +(defvar context-menu--old-down-mouse-3 nil) +(defvar context-menu--old-mouse-3 nil) + +(define-minor-mode context-menu-mode + "Toggle Context Menu mode. + +When Context Menu mode is enabled, clicking the mouse button down-mouse-3 +activates the menu whose contents depends on its surrounding context." + :global t :group 'mouse + (cond + (context-menu-mode + (setq context-menu--old-mouse-3 (global-key-binding [mouse-3])) + (global-unset-key [mouse-3]) + (setq context-menu--old-down-mouse-3 (global-key-binding [down-mouse-3])) + (global-set-key [down-mouse-3] + '(menu-item "Context Menu" ignore + :filter (lambda (_) (context-menu-map))))) + (t + (if (not context-menu--old-down-mouse-3) + (global-unset-key [down-mouse-3]) + (global-set-key [down-mouse-3] context-menu--old-down-mouse-3) + (setq context-menu--old-down-mouse-3 nil)) + (when context-menu--old-mouse-3 + (global-set-key [mouse-3] context-menu--old-mouse-3) + (setq context-menu--old-mouse-3 nil))))) + ;; Commands that operate on windows. -- cgit v1.2.3 From 1493145e3048e057d8ac9e8c9c56d1f99a97eb53 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 21 Jul 2021 21:40:11 +0300 Subject: Change the order of context-menu-functions and add more context menus. * lisp/mouse.el (context-menu-functions): Update default list. (context-menu-overriding-function): Remove variable. (context-menu-map): Reverse the order. (context-menu-global, context-menu-local, context-menu-minor): New functions. (context-menu-undo, context-menu-region): Add separators. Use define-key-after instead of bindings--define-key. (context-menu-entry): New variable. (context-menu-mode): Use it. * lisp/dired.el (dired-context-menu): New function. (dired-mode): Add it to context-menu-functions. * lisp/info.el (Info-context-menu): Reorder. * lisp/net/goto-addr.el (goto-address-at-mouse): Rename from goto-address-at-click. (goto-address-context-menu): Use goto-address-at-mouse. * lisp/progmodes/prog-mode.el (prog-context-menu): New function. (prog-mode): Add it to context-menu-functions. --- lisp/dired.el | 17 ++++++++ lisp/info.el | 53 +++++++++++-------------- lisp/mouse.el | 94 ++++++++++++++++++++++++++++++++++----------- lisp/net/goto-addr.el | 14 +++---- lisp/progmodes/prog-mode.el | 17 ++++++++ 5 files changed, 134 insertions(+), 61 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/dired.el b/lisp/dired.el index 28448be06ce..5e44f524f6b 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2194,6 +2194,22 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." ["Delete Image Tag..." image-dired-delete-tag :help "Delete image tag from current or marked files"])) +(defun dired-context-menu (menu) + (when (mouse-posn-property (event-start last-input-event) 'dired-filename) + (define-key menu [dired-separator-1] menu-bar-separator) + (let ((easy-menu (make-sparse-keymap "Immediate"))) + (easy-menu-define nil easy-menu nil + '("Immediate" + ["Find This File" dired-mouse-find-file + :help "Edit file at mouse click"] + ["Find in Other Window" dired-mouse-find-file-other-window + :help "Edit file at mouse click in other window"])) + (dolist (item (reverse (lookup-key easy-menu [menu-bar immediate]))) + (when (consp item) + (define-key menu (vector (car item)) (cdr item))))) + (define-key menu [dired-separator-2] menu-bar-separator)) + menu) + ;;; Dired mode @@ -2293,6 +2309,7 @@ Keybindings: (append dired-dnd-protocol-alist dnd-protocol-alist))) (add-hook 'file-name-at-point-functions #'dired-file-name-at-point nil t) (add-hook 'isearch-mode-hook #'dired-isearch-filenames-setup nil t) + (add-hook 'context-menu-functions 'dired-context-menu 5 t) (run-mode-hooks 'dired-mode-hook)) diff --git a/lisp/info.el b/lisp/info.el index 226ec76eb67..a8848a94758 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4117,9 +4117,9 @@ If FORK is non-nil, it is passed to `Info-goto-node'." :help "Search for another occurrence of regular expression"] "---" ("History" - ["Back in history" Info-history-back :active Info-history + ["Back in History" Info-history-back :active Info-history :help "Go back in history to the last node you were at"] - ["Forward in history" Info-history-forward :active Info-history-forward + ["Forward in History" Info-history-forward :active Info-history-forward :help "Go forward in history"] ["Show History" Info-history :active Info-history-list :help "Go to menu of visited nodes"]) @@ -4148,34 +4148,25 @@ If FORK is non-nil, it is passed to `Info-goto-node'." (defun Info-context-menu (menu) (when (mouse-posn-property (event-start last-input-event) 'mouse-face) - (bindings--define-key menu [Info-mouse-follow-nearest-node] - '(menu-item "Follow link" Info-mouse-follow-nearest-node - :help "Follow a link where you click"))) - - (bindings--define-key menu [Info-history-back] - '(menu-item "Back in history" Info-history-back :visible Info-history - :help "Go back in history to the last node you were at")) - (bindings--define-key menu [Info-history-forward] - '(menu-item "Forward in history" Info-history-forward :visible Info-history-forward - :help "Go forward in history")) - - (bindings--define-key menu [Info-up] - '(menu-item "Up" Info-up :visible (Info-check-pointer "up") - :help "Go up in the Info tree")) - (bindings--define-key menu [Info-next] - '(menu-item "Next" Info-next :visible (Info-check-pointer "next") - :help "Go to the next node")) - (bindings--define-key menu [Info-prev] - '(menu-item "Previous" Info-prev :visible (Info-check-pointer "prev[ious]*") - :help "Go to the previous node")) - (bindings--define-key menu [Info-backward-node] - '(menu-item "Backward" Info-backward-node - :help "Go backward one node, considering all as a sequence")) - (bindings--define-key menu [Info-forward-node] - '(menu-item "Forward" Info-forward-node - :help "Go forward one node, considering all as a sequence")) - - (define-key menu [Info-separator] menu-bar-separator) + (define-key menu [Info-separator-link-1] menu-bar-separator) + (define-key menu [Info-mouse-follow-nearest-node] + '(menu-item "Follow Link" Info-mouse-follow-nearest-node + :help "Follow a link where you click")) + (define-key menu [Info-separator-link-2] menu-bar-separator)) + + (define-key-after menu [Info-separator-1] menu-bar-separator) + (let ((easy-menu (make-sparse-keymap "Info"))) + (easy-menu-define nil easy-menu nil + '("Info" + ["Back in History" Info-history-back :visible Info-history + :help "Go back in history to the last node you were at"] + ["Forward in History" Info-history-forward :visible Info-history-forward + :help "Go forward in history"])) + (dolist (item (lookup-key easy-menu [menu-bar info])) + (when (consp item) + (define-key-after menu (vector (car item)) (cdr item))))) + (define-key-after menu [Info-separator-2] menu-bar-separator) + menu) (defvar info-tool-bar-map @@ -4477,7 +4468,7 @@ Advanced commands: (add-hook 'clone-buffer-hook 'Info-clone-buffer nil t) (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) (add-hook 'isearch-mode-hook 'Info-isearch-start nil t) - (add-hook 'context-menu-functions 'Info-context-menu nil t) + (add-hook 'context-menu-functions 'Info-context-menu 5 t) (when Info-standalone (add-hook 'quit-window-hook 'save-buffers-kill-emacs nil t)) (setq-local isearch-search-fun-function #'Info-isearch-search) diff --git a/lisp/mouse.el b/lisp/mouse.el index 580fe8eb352..7a564f989c2 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -279,34 +279,77 @@ not it is actually displayed." ;; Context menus. -(defcustom context-menu-functions '(context-menu-undo context-menu-region) +(defcustom context-menu-functions '(context-menu-undo + context-menu-region + context-menu-local + context-menu-minor) "List of functions that produce the contents of the context menu." :type 'hook + :options '(context-menu-undo + context-menu-region + context-menu-global + context-menu-local + context-menu-minor) :version "28.1") -(defvar context-menu-overriding-function nil - "Function that can override the list produced by `context-menu-functions'.") - (defcustom context-menu-filter-function nil "Function that can filter the list produced by `context-menu-functions'." :type 'function :version "28.1") (defun context-menu-map () + "Return composite menu map." (let ((menu (make-sparse-keymap "Context Menu"))) - (if (functionp context-menu-overriding-function) - (setq menu (funcall context-menu-overriding-function menu)) - (run-hook-wrapped 'context-menu-functions - (lambda (fun) - (setq menu (funcall fun menu)) - nil))) - (setq menu (cons (car menu) (nreverse (cdr menu)))) + (run-hook-wrapped 'context-menu-functions + (lambda (fun) + (setq menu (funcall fun menu)) + nil)) (when (functionp context-menu-filter-function) (setq menu (funcall context-menu-filter-function menu))) menu)) +(defun context-menu-global (menu) + "Global submenus." + (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) + (define-key-after menu [separator-global-1] menu-bar-separator) + (dolist (item (lookup-key global-map [menu-bar])) + (when (consp item) + (define-key-after menu (vector (car item)) + (if (consp (cdr item)) + (copy-sequence (cdr item)) + (cdr item))))) + (define-key-after menu [separator-global-2] menu-bar-separator) + menu) + +(defun context-menu-local (menu) + "Major mode submenus." + (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) + (define-key-after menu [separator-local-1] menu-bar-separator) + (dolist (item (local-key-binding [menu-bar])) + (when (consp item) + (define-key-after menu (vector (car item)) + (if (consp (cdr item)) + (copy-sequence (cdr item)) + (cdr item))))) + (define-key-after menu [separator-local-2] menu-bar-separator) + menu) + +(defun context-menu-minor (menu) + "Minor mode submenus." + (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) + (define-key-after menu [separator-minor-1] menu-bar-separator) + (dolist (item (minor-mode-key-binding [menu-bar])) + (when (and (consp item) (symbol-value (car item))) + (define-key-after menu (vector (cadr item)) + (if (consp (cddr item)) + (copy-sequence (cddr item)) + (cddr item))))) + (define-key-after menu [separator-minor-2] menu-bar-separator) + menu) + (defun context-menu-undo (menu) - (bindings--define-key menu [undo] + (define-key-after menu [separator-undo-1] menu-bar-separator) + (define-key-after menu [undo] '(menu-item "Undo" undo :visible (and (not buffer-read-only) (not (eq t buffer-undo-list)) @@ -314,20 +357,22 @@ not it is actually displayed." (listp pending-undo-list) (consp buffer-undo-list))) :help "Undo last edits")) - (bindings--define-key menu [undo-redo] + (define-key-after menu [undo-redo] '(menu-item "Redo" undo-redo :visible (and (not buffer-read-only) (undo--last-change-was-undo-p buffer-undo-list)) :help "Redo last undone edits")) + (define-key-after menu [separator-undo-2] menu-bar-separator) menu) (defun context-menu-region (menu) - (bindings--define-key menu [cut] + (define-key-after menu [separator-region-1] menu-bar-separator) + (define-key-after menu [cut] '(menu-item "Cut" kill-region :visible (and mark-active (not buffer-read-only)) :help "Cut (kill) text in region between mark and current position")) - (bindings--define-key menu [copy] + (define-key-after menu [copy] ;; ns-win.el said: Substitute a Copy function that works better ;; under X (for GNUstep). `(menu-item "Copy" ,(if (featurep 'ns) @@ -338,7 +383,7 @@ not it is actually displayed." :keys ,(if (featurep 'ns) "\\[ns-copy-including-secondary]" "\\[kill-ring-save]"))) - (bindings--define-key menu [paste] + (define-key-after menu [paste] `(menu-item "Paste" mouse-yank-primary :visible (funcall ',(lambda () @@ -349,25 +394,30 @@ not it is actually displayed." kill-ring)) (not buffer-read-only)))) :help "Paste (yank) text most recently cut/copied")) - (bindings--define-key menu (if (featurep 'ns) [select-paste] - [paste-from-menu]) + (define-key-after menu (if (featurep 'ns) [select-paste] + [paste-from-menu]) ;; ns-win.el said: Change text to be more consistent with ;; surrounding menu items `paste', etc." `(menu-item ,(if (featurep 'ns) "Select and Paste" "Paste from Kill Menu") yank-menu :visible (and (cdr yank-menu) (not buffer-read-only)) :help "Choose a string from the kill ring and paste it")) - (bindings--define-key menu [clear] + (define-key-after menu [clear] '(menu-item "Clear" delete-active-region :visible (and mark-active (not buffer-read-only)) :help "Delete the text in region between mark and current position")) - (bindings--define-key menu [mark-whole-buffer] + (define-key-after menu [mark-whole-buffer] '(menu-item "Select All" mark-whole-buffer :help "Mark the whole buffer for a subsequent cut/copy")) + (define-key-after menu [separator-region-2] menu-bar-separator) menu) +(defvar context-menu-entry + `(menu-item ,(purecopy "Context Menu") ignore + :filter (lambda (_) (context-menu-map)))) + (defvar context-menu--old-down-mouse-3 nil) (defvar context-menu--old-mouse-3 nil) @@ -382,9 +432,7 @@ activates the menu whose contents depends on its surrounding context." (setq context-menu--old-mouse-3 (global-key-binding [mouse-3])) (global-unset-key [mouse-3]) (setq context-menu--old-down-mouse-3 (global-key-binding [down-mouse-3])) - (global-set-key [down-mouse-3] - '(menu-item "Context Menu" ignore - :filter (lambda (_) (context-menu-map))))) + (global-set-key [down-mouse-3] context-menu-entry)) (t (if (not context-menu--old-down-mouse-3) (global-unset-key [down-mouse-3]) diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index 1e8a3cda157..2c43d0f7532 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -126,10 +126,10 @@ will have no effect.") (defun goto-address-context-menu (menu) (when (mouse-posn-property (event-start last-input-event) 'goto-address) - (bindings--define-key menu [goto-address-at-click] - '(menu-item "Follow link" goto-address-at-click - :help "Follow a link where you click")) - (define-key menu [goto-address-separator] menu-bar-separator)) + (define-key menu [goto-address-separator] menu-bar-separator) + (define-key menu [goto-address-at-mouse] + '(menu-item "Follow Link" goto-address-at-mouse + :help "Follow a link where you click"))) menu) (defcustom goto-address-url-face 'link @@ -253,8 +253,8 @@ address. If no e-mail address found, return nil." (goto-char (match-beginning 0)))) (match-string-no-properties 0))) -(defun goto-address-at-click (click) - "Send to the e-mail address or load the URL at click." +(defun goto-address-at-mouse (click) + "Send to the e-mail address or load the URL at mouse click." (interactive "e") (goto-address-at-point click)) @@ -280,7 +280,7 @@ Also fontifies the buffer appropriately (see `goto-address-fontify-p' and (cond (goto-address-mode (jit-lock-register #'goto-address-fontify-region) - (add-hook 'context-menu-functions 'goto-address-context-menu -10 t)) + (add-hook 'context-menu-functions 'goto-address-context-menu 10 t)) (t (jit-lock-unregister #'goto-address-fontify-region) (save-restriction diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 19de7545bf3..ad1b13f4bda 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -43,6 +43,22 @@ display-line-numbers-mode prettify-symbols-mode)) +(defun prog-context-menu (menu) + (when (featurep 'xref) + (define-key-after menu [prog-separator-1] menu-bar-separator) + (define-key-after menu [xref-find-def] + '(menu-item "Find Definition" xref-find-definitions-at-mouse + :visible (save-excursion + (mouse-set-point last-input-event) + (xref-backend-identifier-at-point (xref-find-backend))) + :help "Find definition of function or variable")) + (define-key-after menu [xref-pop] + '(menu-item "Back Definition" xref-pop-marker-stack + :visible (not (xref-marker-stack-empty-p)) + :help "Back to the position of the last search")) + (define-key-after menu [prog-separator-2] menu-bar-separator)) + menu) + (defvar prog-mode-map (let ((map (make-sparse-keymap))) (define-key map [?\C-\M-q] 'prog-indent-sexp) @@ -249,6 +265,7 @@ support it." "Major mode for editing programming language source code." (setq-local require-final-newline mode-require-final-newline) (setq-local parse-sexp-ignore-comments t) + (add-hook 'context-menu-functions 'prog-context-menu 10 t) ;; Any programming language is always written left to right. (setq bidi-paragraph-direction 'left-to-right)) -- cgit v1.2.3 From ebac285d0ee567ed86e14b871cf0bac2de8655db Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 21 Jul 2021 23:34:59 +0300 Subject: Improve docstring of context-menu-functions and add eww-context-menu * lisp/mouse.el (context-menu-functions): Explain function args in docstring. * lisp/net/eww.el (eww-context-menu): New function. (eww-mode): Add it to context-menu-functions. * lisp/info.el (Info-context-menu): Move history items higher. * lisp/progmodes/prog-mode.el (prog-context-menu): Add menu items in the middle of the menu after the region menu items. --- lisp/dired.el | 4 ++-- lisp/info.el | 20 +++++++++----------- lisp/mouse.el | 4 +++- lisp/net/eww.el | 31 +++++++++++++++++++++++++++++++ lisp/net/goto-addr.el | 5 +++-- lisp/progmodes/prog-mode.el | 12 ++++++++---- 6 files changed, 56 insertions(+), 20 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/dired.el b/lisp/dired.el index 5e44f524f6b..e16df189a76 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2196,7 +2196,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." (defun dired-context-menu (menu) (when (mouse-posn-property (event-start last-input-event) 'dired-filename) - (define-key menu [dired-separator-1] menu-bar-separator) + (define-key menu [dired-separator-2] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Immediate"))) (easy-menu-define nil easy-menu nil '("Immediate" @@ -2207,7 +2207,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." (dolist (item (reverse (lookup-key easy-menu [menu-bar immediate]))) (when (consp item) (define-key menu (vector (car item)) (cdr item))))) - (define-key menu [dired-separator-2] menu-bar-separator)) + (define-key menu [dired-separator-1] menu-bar-separator)) menu) diff --git a/lisp/info.el b/lisp/info.el index a8848a94758..14dc299295f 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4147,14 +4147,7 @@ If FORK is non-nil, it is passed to `Info-goto-node'." ["Exit" quit-window :help "Stop reading Info"])) (defun Info-context-menu (menu) - (when (mouse-posn-property (event-start last-input-event) 'mouse-face) - (define-key menu [Info-separator-link-1] menu-bar-separator) - (define-key menu [Info-mouse-follow-nearest-node] - '(menu-item "Follow Link" Info-mouse-follow-nearest-node - :help "Follow a link where you click")) - (define-key menu [Info-separator-link-2] menu-bar-separator)) - - (define-key-after menu [Info-separator-1] menu-bar-separator) + (define-key menu [Info-separator-2] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Info"))) (easy-menu-define nil easy-menu nil '("Info" @@ -4162,10 +4155,15 @@ If FORK is non-nil, it is passed to `Info-goto-node'." :help "Go back in history to the last node you were at"] ["Forward in History" Info-history-forward :visible Info-history-forward :help "Go forward in history"])) - (dolist (item (lookup-key easy-menu [menu-bar info])) + (dolist (item (reverse (lookup-key easy-menu [menu-bar info]))) (when (consp item) - (define-key-after menu (vector (car item)) (cdr item))))) - (define-key-after menu [Info-separator-2] menu-bar-separator) + (define-key menu (vector (car item)) (cdr item))))) + + (when (mouse-posn-property (event-start last-input-event) 'mouse-face) + (define-key menu [Info-mouse-follow-nearest-node] + '(menu-item "Follow Link" Info-mouse-follow-nearest-node + :help "Follow a link where you click"))) + (define-key menu [Info-separator-1] menu-bar-separator) menu) diff --git a/lisp/mouse.el b/lisp/mouse.el index 7a564f989c2..37721e60823 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -283,7 +283,9 @@ not it is actually displayed." context-menu-region context-menu-local context-menu-minor) - "List of functions that produce the contents of the context menu." + "List of functions that produce the contents of the context menu. +Each function receives the menu as its argument and should return +the same menu with changes such as added new menu items." :type 'hook :options '(context-menu-undo context-menu-region diff --git a/lisp/net/eww.el b/lisp/net/eww.el index eec3ec7ba8b..b8761029864 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1021,6 +1021,36 @@ the like." ["Toggle Paragraph Direction" eww-toggle-paragraph-direction])) map)) +(defun eww-context-menu (menu) + (define-key menu [eww-separator-2] menu-bar-separator) + (let ((easy-menu (make-sparse-keymap "Eww"))) + (easy-menu-define nil easy-menu nil + '("Eww" + ["Back to previous page" eww-back-url + :visible (not (zerop (length eww-history)))] + ["Forward to next page" eww-forward-url + :visible (not (zerop eww-history-position))] + ["Reload" eww-reload t])) + (dolist (item (reverse (lookup-key easy-menu [menu-bar eww]))) + (when (consp item) + (define-key menu (vector (car item)) (cdr item))))) + + (when (or (mouse-posn-property (event-start last-input-event) 'shr-url) + (mouse-posn-property (event-start last-input-event) 'image-url)) + (define-key menu [shr-mouse-browse-url-new-window] + `(menu-item "Follow URL in new window" ,(if browse-url-new-window-flag + 'shr-mouse-browse-url + 'shr-mouse-browse-url-new-window) + :help "Browse the URL under the mouse cursor in a new window")) + (define-key menu [shr-mouse-browse-url] + `(menu-item "Follow URL" ,(if browse-url-new-window-flag + 'shr-mouse-browse-url-new-window + 'shr-mouse-browse-url) + :help "Browse the URL under the mouse cursor"))) + (define-key menu [eww-separator-1] menu-bar-separator) + + menu) + (defvar eww-tool-bar-map (let ((map (make-sparse-keymap))) (dolist (tool-bar-item @@ -1044,6 +1074,7 @@ the like." (setq-local eww-data (list :title "")) (setq-local browse-url-browser-function #'eww-browse-url) (add-hook 'after-change-functions #'eww-process-text-input nil t) + (add-hook 'context-menu-functions 'eww-context-menu 5 t) (setq-local eww-history nil) (setq-local eww-history-position 0) (when (boundp 'tool-bar-map) diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index 2c43d0f7532..c270cf53cbf 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -126,10 +126,11 @@ will have no effect.") (defun goto-address-context-menu (menu) (when (mouse-posn-property (event-start last-input-event) 'goto-address) - (define-key menu [goto-address-separator] menu-bar-separator) + (define-key menu [goto-address-separator-2] menu-bar-separator) (define-key menu [goto-address-at-mouse] '(menu-item "Follow Link" goto-address-at-mouse - :help "Follow a link where you click"))) + :help "Follow a link where you click")) + (define-key menu [goto-address-separator-1] menu-bar-separator)) menu) (defcustom goto-address-url-face 'link diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index ad1b13f4bda..a10291a9c7d 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -45,18 +45,22 @@ (defun prog-context-menu (menu) (when (featurep 'xref) - (define-key-after menu [prog-separator-1] menu-bar-separator) + (define-key-after menu [prog-separator-1] menu-bar-separator + 'separator-region-2) (define-key-after menu [xref-find-def] '(menu-item "Find Definition" xref-find-definitions-at-mouse :visible (save-excursion (mouse-set-point last-input-event) (xref-backend-identifier-at-point (xref-find-backend))) - :help "Find definition of function or variable")) + :help "Find definition of function or variable") + 'prog-separator-1) (define-key-after menu [xref-pop] '(menu-item "Back Definition" xref-pop-marker-stack :visible (not (xref-marker-stack-empty-p)) - :help "Back to the position of the last search")) - (define-key-after menu [prog-separator-2] menu-bar-separator)) + :help "Back to the position of the last search") + 'xref-find-def) + (define-key-after menu [prog-separator-2] menu-bar-separator + 'xref-pop)) menu) (defvar prog-mode-map -- cgit v1.2.3 From 2c2baa9d1231ad9e642e3a80fb1c641fdde71b33 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 27 Jul 2021 23:48:07 +0300 Subject: Add new context-menu options for menus "File At Point" and "Version Control". * lisp/mouse.el (context-menu-functions): Add more options. (context-menu-global, context-menu-local): Fix separators. (context-menu-minor): Rewrite to support list of submenus. (context-menu-vc, context-menu-ffap): New functions. (context-menu-undo, context-menu-region): Fix separators. * lisp/dired.el (dired-context-menu): * lisp/info.el (Info-context-menu): * lisp/net/goto-addr.el (goto-address-context-menu): * lisp/net/eww.el (eww-context-menu): * lisp/progmodes/prog-mode.el (prog-context-menu): Fix separators. --- lisp/dired.el | 5 ++--- lisp/info.el | 3 +-- lisp/mouse.el | 51 ++++++++++++++++++++++++++++++--------------- lisp/net/eww.el | 3 +-- lisp/net/goto-addr.el | 5 ++--- lisp/progmodes/prog-mode.el | 10 ++++----- 6 files changed, 44 insertions(+), 33 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/dired.el b/lisp/dired.el index e16df189a76..4e82d57e216 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2196,7 +2196,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." (defun dired-context-menu (menu) (when (mouse-posn-property (event-start last-input-event) 'dired-filename) - (define-key menu [dired-separator-2] menu-bar-separator) + (define-key menu [dired-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Immediate"))) (easy-menu-define nil easy-menu nil '("Immediate" @@ -2206,8 +2206,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." :help "Edit file at mouse click in other window"])) (dolist (item (reverse (lookup-key easy-menu [menu-bar immediate]))) (when (consp item) - (define-key menu (vector (car item)) (cdr item))))) - (define-key menu [dired-separator-1] menu-bar-separator)) + (define-key menu (vector (car item)) (cdr item)))))) menu) diff --git a/lisp/info.el b/lisp/info.el index 14dc299295f..0b3a9e4bf5d 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4147,7 +4147,7 @@ If FORK is non-nil, it is passed to `Info-goto-node'." ["Exit" quit-window :help "Stop reading Info"])) (defun Info-context-menu (menu) - (define-key menu [Info-separator-2] menu-bar-separator) + (define-key menu [Info-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Info"))) (easy-menu-define nil easy-menu nil '("Info" @@ -4163,7 +4163,6 @@ If FORK is non-nil, it is passed to `Info-goto-node'." (define-key menu [Info-mouse-follow-nearest-node] '(menu-item "Follow Link" Info-mouse-follow-nearest-node :help "Follow a link where you click"))) - (define-key menu [Info-separator-1] menu-bar-separator) menu) diff --git a/lisp/mouse.el b/lisp/mouse.el index 37721e60823..60c4f4b85c5 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -291,7 +291,9 @@ the same menu with changes such as added new menu items." context-menu-region context-menu-global context-menu-local - context-menu-minor) + context-menu-minor + context-menu-vc + context-menu-ffap) :version "28.1") (defcustom context-menu-filter-function nil @@ -313,44 +315,50 @@ the same menu with changes such as added new menu items." (defun context-menu-global (menu) "Global submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) - (define-key-after menu [separator-global-1] menu-bar-separator) + (define-key-after menu [separator-global] menu-bar-separator) (dolist (item (lookup-key global-map [menu-bar])) (when (consp item) (define-key-after menu (vector (car item)) (if (consp (cdr item)) (copy-sequence (cdr item)) (cdr item))))) - (define-key-after menu [separator-global-2] menu-bar-separator) menu) (defun context-menu-local (menu) "Major mode submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) - (define-key-after menu [separator-local-1] menu-bar-separator) + (define-key-after menu [separator-local] menu-bar-separator) (dolist (item (local-key-binding [menu-bar])) (when (consp item) (define-key-after menu (vector (car item)) (if (consp (cdr item)) (copy-sequence (cdr item)) (cdr item))))) - (define-key-after menu [separator-local-2] menu-bar-separator) menu) (defun context-menu-minor (menu) "Minor mode submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) - (define-key-after menu [separator-minor-1] menu-bar-separator) - (dolist (item (minor-mode-key-binding [menu-bar])) - (when (and (consp item) (symbol-value (car item))) - (define-key-after menu (vector (cadr item)) - (if (consp (cddr item)) - (copy-sequence (cddr item)) - (cddr item))))) - (define-key-after menu [separator-minor-2] menu-bar-separator) + (define-key-after menu [separator-minor] menu-bar-separator) + (dolist (mode (minor-mode-key-binding [menu-bar])) + (when (and (consp mode) (symbol-value (car mode))) + (dolist (item (cdr mode)) + (when (consp item) + (define-key-after menu (vector (car item)) + (if (consp (cdr item)) + (copy-sequence (cdr item)) + (cdr item))))))) + menu) + +(defun context-menu-vc (menu) + "Version Control menu." + (define-key-after menu [separator-vc] menu-bar-separator) + (define-key-after menu [vc-menu] vc-menu-entry) menu) (defun context-menu-undo (menu) - (define-key-after menu [separator-undo-1] menu-bar-separator) + (when (cddr menu) + (define-key-after menu [separator-undo] menu-bar-separator)) (define-key-after menu [undo] '(menu-item "Undo" undo :visible (and (not buffer-read-only) @@ -364,11 +372,11 @@ the same menu with changes such as added new menu items." :visible (and (not buffer-read-only) (undo--last-change-was-undo-p buffer-undo-list)) :help "Redo last undone edits")) - (define-key-after menu [separator-undo-2] menu-bar-separator) menu) (defun context-menu-region (menu) - (define-key-after menu [separator-region-1] menu-bar-separator) + (when (cddr menu) + (define-key-after menu [separator-region] menu-bar-separator)) (define-key-after menu [cut] '(menu-item "Cut" kill-region :visible (and mark-active (not buffer-read-only)) @@ -413,7 +421,16 @@ the same menu with changes such as added new menu items." (define-key-after menu [mark-whole-buffer] '(menu-item "Select All" mark-whole-buffer :help "Mark the whole buffer for a subsequent cut/copy")) - (define-key-after menu [separator-region-2] menu-bar-separator) + menu) + +(defun context-menu-ffap (menu) + (save-excursion + (mouse-set-point last-input-event) + (when (ffap-guess-file-name-at-point) + (define-key menu [ffap-separator] menu-bar-separator) + (define-key menu [ffap-at-mouse] + '(menu-item "Find File or URL" ffap-at-mouse + :help "Find file or URL guessed from text around mouse click")))) menu) (defvar context-menu-entry diff --git a/lisp/net/eww.el b/lisp/net/eww.el index b8761029864..5c46ccfe001 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1022,7 +1022,7 @@ the like." map)) (defun eww-context-menu (menu) - (define-key menu [eww-separator-2] menu-bar-separator) + (define-key menu [eww-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Eww"))) (easy-menu-define nil easy-menu nil '("Eww" @@ -1047,7 +1047,6 @@ the like." 'shr-mouse-browse-url-new-window 'shr-mouse-browse-url) :help "Browse the URL under the mouse cursor"))) - (define-key menu [eww-separator-1] menu-bar-separator) menu) diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index c270cf53cbf..2c43d0f7532 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -126,11 +126,10 @@ will have no effect.") (defun goto-address-context-menu (menu) (when (mouse-posn-property (event-start last-input-event) 'goto-address) - (define-key menu [goto-address-separator-2] menu-bar-separator) + (define-key menu [goto-address-separator] menu-bar-separator) (define-key menu [goto-address-at-mouse] '(menu-item "Follow Link" goto-address-at-mouse - :help "Follow a link where you click")) - (define-key menu [goto-address-separator-1] menu-bar-separator)) + :help "Follow a link where you click"))) menu) (defcustom goto-address-url-face 'link diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index a10291a9c7d..a8b608b018a 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -45,22 +45,20 @@ (defun prog-context-menu (menu) (when (featurep 'xref) - (define-key-after menu [prog-separator-1] menu-bar-separator - 'separator-region-2) + (define-key-after menu [prog-separator] menu-bar-separator + 'mark-whole-buffer) (define-key-after menu [xref-find-def] '(menu-item "Find Definition" xref-find-definitions-at-mouse :visible (save-excursion (mouse-set-point last-input-event) (xref-backend-identifier-at-point (xref-find-backend))) :help "Find definition of function or variable") - 'prog-separator-1) + 'prog-separator) (define-key-after menu [xref-pop] '(menu-item "Back Definition" xref-pop-marker-stack :visible (not (xref-marker-stack-empty-p)) :help "Back to the position of the last search") - 'xref-find-def) - (define-key-after menu [prog-separator-2] menu-bar-separator - 'xref-pop)) + 'xref-find-def)) menu) (defvar prog-mode-map -- cgit v1.2.3 From ee1887bf54e7091a382ad24691ce0f482c61d7ea Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 28 Jul 2021 19:40:23 +0300 Subject: Improve :type of defcustom 'context-menu-functions' and add documentation. * doc/emacs/frames.texi (Menu Mouse Clicks): Describe context-menu-mode and context-menu-functions instead of suggesting global-set-key. (Menu Bars): Mention context-menu-mode and context-menu-functions. * etc/NEWS: Add context-menu-mode and context-menu-functions. * lisp/mouse.el (context-menu-functions): Use :type with repeat/function-item. (context-menu-minor, context-menu-undo, context-menu-region) (context-menu-ffap): Improve docstrings displayed for function-item in defcustom of context-menu-functions. --- doc/emacs/frames.texi | 25 +++++++++++-------------- etc/NEWS | 11 ++++++++++- lisp/mouse.el | 22 +++++++++++++--------- 3 files changed, 34 insertions(+), 24 deletions(-) (limited to 'lisp/mouse.el') diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi index 70615f68ed8..e03fb95755b 100644 --- a/doc/emacs/frames.texi +++ b/doc/emacs/frames.texi @@ -366,20 +366,15 @@ This menu is for changing the default face within the window's buffer. @xref{Text Scale}. @end table +@cindex context menu +@findex context-menu-mode +@vindex context-menu-functions +@kindex Down-mouse-3 Some graphical applications use @kbd{mouse-3} for a mode-specific -menu. If you prefer @kbd{mouse-3} in Emacs to bring up such a menu -instead of running the @code{mouse-save-then-kill} command, rebind -@kbd{mouse-3} by adding the following line to your init file -(@pxref{Init Rebinding}): - -@smallexample -(global-set-key [mouse-3] - '(menu-item "Menu Bar" ignore - :filter (lambda (_) - (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0)) - (mouse-menu-bar-map) - (mouse-menu-major-mode-map))))) -@end smallexample +menu. If you prefer @kbd{mouse-3} in Emacs to bring up such a context +menu instead of running the @code{mouse-save-then-kill} command, +enable @code{context-menu-mode} and customize the variable +@code{context-menu-functions}. @node Mode Line Mouse @section Mode Line Mouse Commands @@ -1217,7 +1212,9 @@ the use of menu bars at startup, customize the variable terminals, where this makes one additional line available for text. If the menu bar is off, you can still pop up a menu of its contents with @kbd{C-mouse-3} on a display which supports pop-up menus. -@xref{Menu Mouse Clicks}. +Or you can enable @code{context-menu-mode} and customize the variable +@code{context-menu-functions} to pop up a context menu with +@kbd{mouse-3}. @xref{Menu Mouse Clicks}. @xref{Menu Bar}, for information on how to invoke commands with the menu bar. @xref{X Resources}, for how to customize the menu bar diff --git a/etc/NEWS b/etc/NEWS index 49396c321dc..4ca2623e9a1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -346,8 +346,17 @@ onto 'file-name-history'. +++ ** A prefix arg now causes 'delete-other-frames' to only iconify frames. +** Menus + ++++ +*** New mode 'context-menu-mode' for a context menu bound to 'mouse-3'. +When this mode is enabled, clicking 'down-mouse-3' anywhere in the buffer +pops up a context menu whose contents depends on surrounding context +near the mouse click. You can customize the order of the default submenus +in the context menu by customizing the user option 'context-menu-functions'. + +++ -** The "Edit => Clear" menu item now obeys a rectangular region. +*** The "Edit => Clear" menu item now obeys a rectangular region. +++ ** New command 'execute-extended-command-for-buffer'. diff --git a/lisp/mouse.el b/lisp/mouse.el index 60c4f4b85c5..49191e32ea4 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -286,14 +286,15 @@ not it is actually displayed." "List of functions that produce the contents of the context menu. Each function receives the menu as its argument and should return the same menu with changes such as added new menu items." - :type 'hook - :options '(context-menu-undo - context-menu-region - context-menu-global - context-menu-local - context-menu-minor - context-menu-vc - context-menu-ffap) + :type '(repeat + (choice (function-item context-menu-undo) + (function-item context-menu-region) + (function-item context-menu-global) + (function-item context-menu-local) + (function-item context-menu-minor) + (function-item context-menu-vc) + (function-item context-menu-ffap) + (function :tag "Custom function"))) :version "28.1") (defcustom context-menu-filter-function nil @@ -337,7 +338,7 @@ the same menu with changes such as added new menu items." menu) (defun context-menu-minor (menu) - "Minor mode submenus." + "Minor modes submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-minor] menu-bar-separator) (dolist (mode (minor-mode-key-binding [menu-bar])) @@ -357,6 +358,7 @@ the same menu with changes such as added new menu items." menu) (defun context-menu-undo (menu) + "Undo menu." (when (cddr menu) (define-key-after menu [separator-undo] menu-bar-separator)) (define-key-after menu [undo] @@ -375,6 +377,7 @@ the same menu with changes such as added new menu items." menu) (defun context-menu-region (menu) + "Region commands menu." (when (cddr menu) (define-key-after menu [separator-region] menu-bar-separator)) (define-key-after menu [cut] @@ -424,6 +427,7 @@ the same menu with changes such as added new menu items." menu) (defun context-menu-ffap (menu) + "File at point menu." (save-excursion (mouse-set-point last-input-event) (when (ffap-guess-file-name-at-point) -- cgit v1.2.3 From de5601f0902b05f594bd2254b23032ed4c598f9d Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 3 Aug 2021 11:23:57 +0300 Subject: Improve handling of context menus for global, local, minor-mode menus * lisp/mouse.el (context-menu-global, context-menu-local, context-menu-minor): Better handling of possibly nested menu maps. --- lisp/mouse.el | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 49191e32ea4..1f5bd8e4a6b 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -318,11 +318,9 @@ the same menu with changes such as added new menu items." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-global] menu-bar-separator) (dolist (item (lookup-key global-map [menu-bar])) - (when (consp item) + (when (and (consp item) (consp (cdr item))) (define-key-after menu (vector (car item)) - (if (consp (cdr item)) - (copy-sequence (cdr item)) - (cdr item))))) + (copy-sequence (cdr item))))) menu) (defun context-menu-local (menu) @@ -330,11 +328,11 @@ the same menu with changes such as added new menu items." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-local] menu-bar-separator) (dolist (item (local-key-binding [menu-bar])) - (when (consp item) + (when (and (consp item) (consp (cdr item))) + ;; Fix deep menu created by `imenu-add-to-menubar'. + (when (eq (car item) 'keymap) (setq item (cadr item))) (define-key-after menu (vector (car item)) - (if (consp (cdr item)) - (copy-sequence (cdr item)) - (cdr item))))) + (copy-sequence (cdr item))))) menu) (defun context-menu-minor (menu) @@ -344,11 +342,9 @@ the same menu with changes such as added new menu items." (dolist (mode (minor-mode-key-binding [menu-bar])) (when (and (consp mode) (symbol-value (car mode))) (dolist (item (cdr mode)) - (when (consp item) + (when (and (consp item) (consp (cdr item))) (define-key-after menu (vector (car item)) - (if (consp (cdr item)) - (copy-sequence (cdr item)) - (cdr item))))))) + (copy-sequence (cdr item))))))) menu) (defun context-menu-vc (menu) -- cgit v1.2.3 From 051434fdefd6418bf1f0cd28c087b31cb3921f48 Mon Sep 17 00:00:00 2001 From: Mattias EngdegĂ„rd Date: Sun, 8 Aug 2021 18:58:46 +0200 Subject: Use string-replace instead of replace-regexp-in-string `string-replace` is easier to understand, less error-prone, much faster, and results in shorter Lisp and byte code. Use it where applicable and obviously safe (erring on the conservative side). * admin/authors.el (authors-scan-change-log): * lisp/autoinsert.el (auto-insert-alist): * lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent) (calc-edit-macro-combine-ext-command) (calc-edit-macro-combine-var-name): * lisp/calc/calc-units.el (math-make-unit-string): * lisp/calendar/cal-html.el (cal-html-comment): * lisp/calendar/cal-tex.el (cal-tex-comment): * lisp/calendar/icalendar.el (icalendar--convert-string-for-export) (icalendar--convert-string-for-import): * lisp/calendar/iso8601.el (iso8601--concat-regexps) (iso8601--full-time-match, iso8601--combined-match): * lisp/calendar/time-date.el (format-seconds): * lisp/calendar/todo-mode.el (todo-filter-items-filename): * lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name) (cedet-file-name-to-directory-name): * lisp/comint.el (comint-watch-for-password-prompt): * lisp/dired-aux.el (dired-do-chmod): * lisp/dired-x.el (dired-man): * lisp/dired.el (dired-insert-directory, dired-goto-file-1): * lisp/emacs-lisp/comp.el (comp-c-func-name): * lisp/emacs-lisp/re-builder.el (reb-copy): * lisp/erc/erc-dcc.el (erc-dcc-unquote-filename): * lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy) (erc-update-mode-line-buffer, erc-message-english-PART): * lisp/files.el (make-backup-file-name-1, files--transform-file-name) (read-file-modes): * lisp/fringe.el (fringe-mode): * lisp/gnus/gnus-art.el (gnus-button-handle-info-url): * lisp/gnus/gnus-group.el (gnus-group-completing-read): * lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical): * lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy): * lisp/gnus/gnus-search.el (gnus-search-query-parse-date) (gnus-search-transform-expression, gnus-search-run-search): * lisp/gnus/gnus-start.el (gnus-dribble-enter): * lisp/gnus/gnus-sum.el (gnus-summary-refer-article): * lisp/gnus/gnus-util.el (gnus-mode-string-quote): * lisp/gnus/message.el (message-put-addresses-in-ecomplete) (message-parse-mailto-url, message-mailto-1): * lisp/gnus/mml-sec.el (mml-secure-epg-sign): * lisp/gnus/mml-smime.el (mml-smime-epg-verify): * lisp/gnus/mml2015.el (mml2015-epg-verify): * lisp/gnus/nnmaildir.el (nnmaildir--system-name) (nnmaildir-request-list, nnmaildir-retrieve-groups) (nnmaildir-request-group, nnmaildir-retrieve-headers): * lisp/gnus/nnrss.el (nnrss-node-text): * lisp/gnus/spam-report.el (spam-report-gmane-internal) (spam-report-user-mail-address): * lisp/ibuffer.el (name): * lisp/image-dired.el (image-dired-pngnq-thumb) (image-dired-pngcrush-thumb, image-dired-optipng-thumb) (image-dired-create-thumb-1): * lisp/info.el (Info-set-mode-line): * lisp/international/mule-cmds.el (describe-language-environment): * lisp/mail/rfc2231.el (rfc2231-parse-string): * lisp/mail/rfc2368.el (rfc2368-parse-mailto-url): * lisp/mail/rmail.el (rmail-insert-inbox-text) (rmail-simplified-subject-regexp): * lisp/mail/rmailout.el (rmail-output-body-to-file): * lisp/mail/undigest.el (rmail-digest-rfc1153): * lisp/man.el (Man-default-man-entry): * lisp/mouse.el (minor-mode-menu-from-indicator): * lisp/mpc.el (mpc--debug): * lisp/net/browse-url.el (browse-url-mail): * lisp/net/eww.el (eww-update-header-line-format): * lisp/net/newst-backend.el (newsticker-save-item): * lisp/net/rcirc.el (rcirc-sentinel): * lisp/net/soap-client.el (soap-decode-date-time): * lisp/nxml/rng-cmpct.el (rng-c-literal-2-re): * lisp/nxml/xmltok.el (let*): * lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex) (nnir-run-find-grep): * lisp/play/dunnet.el (dun-doassign): * lisp/play/handwrite.el (handwrite): * lisp/proced.el (proced-format-args): * lisp/profiler.el (profiler-report-header-line-format): * lisp/progmodes/gdb-mi.el (gdb-mi-quote): * lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex) (makefile-make-font-lock-keywords): * lisp/progmodes/prolog.el (prolog-guess-fill-prefix): * lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes): * lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal): * lisp/progmodes/which-func.el (which-func-current): * lisp/replace.el (query-replace-read-from) (occur-engine, replace-quote): * lisp/select.el (xselect--encode-string): * lisp/ses.el (ses-export-tab): * lisp/subr.el (shell-quote-argument): * lisp/term/pc-win.el (msdos-show-help): * lisp/term/w32-win.el (w32--set-selection): * lisp/term/xterm.el (gui-backend-set-selection): * lisp/textmodes/picture.el (picture-tab-search): * lisp/thumbs.el (thumbs-call-setroot-command): * lisp/tooltip.el (tooltip-show-help-non-mode): * lisp/transient.el (transient-format-key): * lisp/url/url-mailto.el (url-mailto): * lisp/vc/log-edit.el (log-edit-changelog-ours-p): * lisp/vc/vc-bzr.el (vc-bzr-status): * lisp/vc/vc-hg.el (vc-hg--glob-to-pcre): * lisp/vc/vc-svn.el (vc-svn-after-dir-status): * lisp/xdg.el (xdg-desktop-strings): * test/lisp/electric-tests.el (defun): * test/lisp/term-tests.el (term-simple-lines): * test/lisp/time-stamp-tests.el (formatz-mod-del-colons): * test/lisp/wdired-tests.el (wdired-test-bug32173-01) (wdired-test-unfinished-edit-01): * test/src/json-tests.el (json-parse-with-custom-null-and-false-objects): Use `string-replace` instead of `replace-regexp-in-string`. --- admin/authors.el | 2 +- lisp/autoinsert.el | 4 ++-- lisp/calc/calc-prog.el | 8 ++++---- lisp/calc/calc-units.el | 2 +- lisp/calendar/cal-html.el | 2 +- lisp/calendar/cal-tex.el | 2 +- lisp/calendar/icalendar.el | 12 ++++++------ lisp/calendar/iso8601.el | 6 +++--- lisp/calendar/time-date.el | 2 +- lisp/calendar/todo-mode.el | 2 +- lisp/cedet/cedet-files.el | 4 ++-- lisp/comint.el | 2 +- lisp/dired-aux.el | 2 +- lisp/dired-x.el | 2 +- lisp/dired.el | 14 +++++++------- lisp/emacs-lisp/comp.el | 2 +- lisp/emacs-lisp/re-builder.el | 2 +- lisp/erc/erc-dcc.el | 4 ++-- lisp/erc/erc.el | 8 ++++---- lisp/files.el | 6 +++--- lisp/fringe.el | 2 +- lisp/gnus/gnus-art.el | 2 +- lisp/gnus/gnus-group.el | 2 +- lisp/gnus/gnus-icalendar.el | 8 ++++---- lisp/gnus/gnus-mlspl.el | 2 +- lisp/gnus/gnus-search.el | 10 +++++----- lisp/gnus/gnus-start.el | 2 +- lisp/gnus/gnus-sum.el | 2 +- lisp/gnus/gnus-util.el | 2 +- lisp/gnus/message.el | 8 ++++---- lisp/gnus/mml-sec.el | 2 +- lisp/gnus/mml-smime.el | 2 +- lisp/gnus/mml2015.el | 2 +- lisp/gnus/nnmaildir.el | 18 ++++++++---------- lisp/gnus/nnrss.el | 2 +- lisp/gnus/spam-report.el | 4 ++-- lisp/ibuffer.el | 2 +- lisp/image-dired.el | 8 ++++---- lisp/info.el | 4 ++-- lisp/international/mule-cmds.el | 2 +- lisp/mail/rfc2231.el | 2 +- lisp/mail/rfc2368.el | 2 +- lisp/mail/rmail.el | 4 ++-- lisp/mail/rmailout.el | 4 ++-- lisp/mail/undigest.el | 2 +- lisp/man.el | 2 +- lisp/mouse.el | 2 +- lisp/mpc.el | 4 ++-- lisp/net/browse-url.el | 2 +- lisp/net/eww.el | 2 +- lisp/net/newst-backend.el | 2 +- lisp/net/rcirc.el | 2 +- lisp/net/soap-client.el | 2 +- lisp/nxml/rng-cmpct.el | 2 +- lisp/nxml/xmltok.el | 2 +- lisp/obsolete/nnir.el | 12 ++++++------ lisp/play/dunnet.el | 2 +- lisp/play/handwrite.el | 2 +- lisp/proced.el | 2 +- lisp/profiler.el | 2 +- lisp/progmodes/gdb-mi.el | 2 +- lisp/progmodes/make-mode.el | 7 +++---- lisp/progmodes/prolog.el | 2 +- lisp/progmodes/ruby-mode.el | 4 ++-- lisp/progmodes/sql.el | 4 ++-- lisp/progmodes/which-func.el | 2 +- lisp/replace.el | 14 ++++++-------- lisp/select.el | 2 +- lisp/ses.el | 2 +- lisp/subr.el | 2 +- lisp/term/pc-win.el | 2 +- lisp/term/w32-win.el | 2 +- lisp/term/xterm.el | 5 ++--- lisp/textmodes/picture.el | 4 ++-- lisp/thumbs.el | 6 +++--- lisp/tooltip.el | 2 +- lisp/transient.el | 12 ++++++------ lisp/url/url-mailto.el | 2 +- lisp/vc/log-edit.el | 4 ++-- lisp/vc/vc-bzr.el | 2 +- lisp/vc/vc-hg.el | 4 ++-- lisp/vc/vc-svn.el | 2 +- lisp/xdg.el | 4 ++-- test/lisp/electric-tests.el | 2 +- test/lisp/term-tests.el | 2 +- test/lisp/time-stamp-tests.el | 2 +- test/lisp/wdired-tests.el | 4 ++-- test/src/json-tests.el | 2 +- 88 files changed, 164 insertions(+), 170 deletions(-) (limited to 'lisp/mouse.el') diff --git a/admin/authors.el b/admin/authors.el index 6c81c7872fc..a400b1327af 100644 --- a/admin/authors.el +++ b/admin/authors.el @@ -1475,7 +1475,7 @@ Suggested\\|Trivial\\|Version\\|Originally\\|From:\\|Patch[ \t]+[Bb]y\\)"))) (when (string-match ":" line) (setq line (substring line 0 (match-beginning 0))) (setq line (replace-regexp-in-string "[[(<{].*$" "" line)) - (setq line (replace-regexp-in-string "," "" line)) + (setq line (string-replace "," "" line)) (dolist (file (split-string line)) (when (setq file (authors-canonical-file-name file log-file pos (car authors))) (dolist (author authors) diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el index 0392903c332..995d9e2e0fe 100644 --- a/lisp/autoinsert.el +++ b/lisp/autoinsert.el @@ -93,8 +93,8 @@ If this contains a %s, that will be replaced by the matching rule." '((("\\.\\([Hh]\\|hh\\|hpp\\|hxx\\|h\\+\\+\\)\\'" . "C / C++ header") (replace-regexp-in-string "[^A-Z0-9]" "_" - (replace-regexp-in-string - "\\+" "P" + (string-replace + "+" "P" (upcase (file-name-nondirectory buffer-file-name)))) "#ifndef " str \n "#define " str "\n\n" diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el index 4e27d7671e2..6f1e5c782df 100644 --- a/lisp/calc/calc-prog.el +++ b/lisp/calc/calc-prog.el @@ -802,8 +802,8 @@ (when match (kill-line 1) (setq line (concat line (substring curline 0 match)))) - (setq line (replace-regexp-in-string "SPC" " SPC " - (replace-regexp-in-string " " "" line))) + (setq line (string-replace "SPC" " SPC " + (string-replace " " "" line))) (insert line "\t\t\t") (if (> (current-column) 24) (delete-char -1)) @@ -830,7 +830,7 @@ (when match (kill-line 1) (setq line (concat line (substring curline 0 match)))) - (setq line (replace-regexp-in-string " " "" line)) + (setq line (string-replace " " "" line)) (insert cmdbeg " " line "\t\t\t") (if (> (current-column) 24) (delete-char -1)) @@ -857,7 +857,7 @@ (when match (kill-line 1) (setq line (concat line (substring curline 0 match)))) - (setq line (replace-regexp-in-string " " "" line)) + (setq line (string-replace " " "" line)) (insert line "\t\t\t") (if (> (current-column) 24) (delete-char -1)) diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el index c3adc3db02a..8b6f0637035 100644 --- a/lisp/calc/calc-units.el +++ b/lisp/calc/calc-units.el @@ -406,7 +406,7 @@ Entries are (SYMBOL EXPR DOC-STRING TEMP-TYPE BASE-UNITS).") If EXPR is nil, return nil." (if expr (let ((cexpr (math-compose-expr expr 0))) - (replace-regexp-in-string + (string-replace " / " "/" (if (stringp cexpr) cexpr diff --git a/lisp/calendar/cal-html.el b/lisp/calendar/cal-html.el index e5810c3f027..58a5a0f83a5 100644 --- a/lisp/calendar/cal-html.el +++ b/lisp/calendar/cal-html.el @@ -151,7 +151,7 @@ (defun cal-html-comment (string) "Return STRING as html comment." (format "\n" - (replace-regexp-in-string "--" "++" string))) + (string-replace "--" "++" string))) (defun cal-html-href (link string) "Return a hyperlink to url LINK with text STRING." diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el index f5932014dd9..3830024ef3d 100644 --- a/lisp/calendar/cal-tex.el +++ b/lisp/calendar/cal-tex.el @@ -1755,7 +1755,7 @@ current contents." COMMENT may contain newlines, which are prefixed by \"% \" in the output." (insert (format "%% %s\n" (if comment - (replace-regexp-in-string "\n" "\n% " comment) + (string-replace "\n" "\n% " comment) "")))) (defun cal-tex-banner (comment) diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index d18ec5e798f..cf37331394c 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -998,15 +998,15 @@ TIMESTRING and has the same result as \"9:00\"." (defun icalendar--convert-string-for-export (string) "Escape comma and other critical characters in STRING." - (replace-regexp-in-string "," "\\\\," string)) + (string-replace "," "\\," string)) (defun icalendar--convert-string-for-import (string) "Remove escape chars for comma, semicolon etc. from STRING." - (replace-regexp-in-string - "\\\\n" "\n " (replace-regexp-in-string - "\\\\\"" "\"" (replace-regexp-in-string - "\\\\;" ";" (replace-regexp-in-string - "\\\\," "," string))))) + (string-replace + "\\n" "\n " (string-replace + "\\\"" "\"" (string-replace + "\\;" ";" (string-replace + "\\," "," string))))) ;; ====================================================================== ;; Export -- convert emacs-diary to iCalendar diff --git a/lisp/calendar/iso8601.el b/lisp/calendar/iso8601.el index f22f060e205..1de1796a054 100644 --- a/lisp/calendar/iso8601.el +++ b/lisp/calendar/iso8601.el @@ -57,7 +57,7 @@ (defun iso8601--concat-regexps (regexps) (mapconcat (lambda (regexp) (concat "\\(?:" - (replace-regexp-in-string "(" "(?:" regexp) + (string-replace "(" "(?:" regexp) "\\)")) regexps "\\|")) @@ -92,13 +92,13 @@ "\\(Z\\|\\([+-]\\)\\([0-9][0-9]\\):?\\([0-9][0-9]\\)?\\)") (defconst iso8601--full-time-match - (concat "\\(" (replace-regexp-in-string "(" "(?:" iso8601--time-match) "\\)" + (concat "\\(" (string-replace "(" "(?:" iso8601--time-match) "\\)" "\\(" iso8601--zone-match "\\)?")) (defconst iso8601--combined-match (concat "\\(" iso8601--date-match "\\)" "\\(?:T\\(" - (replace-regexp-in-string "(" "(?:" iso8601--time-match) + (string-replace "(" "(?:" iso8601--time-match) "\\)" "\\(" iso8601--zone-match "\\)?\\)?")) diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index 1c169b78fd6..0aa38166bc1 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -357,7 +357,7 @@ is output until the first non-zero unit is encountered." (format " %s%s" name (if (= num 1) "" "s")))) t t string)))))) - (replace-regexp-in-string "%%" "%" string)) + (string-replace "%%" "%" string)) (defvar seconds-to-string (list (list 1 "ms" 0.001) diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 680beb85aff..371d10631c5 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -4546,7 +4546,7 @@ its priority has changed, and `same' otherwise." (let ((bufname (buffer-name))) (string-match "\"\\([^\"]+\\)\"" bufname) (let* ((filename-str (substring bufname (match-beginning 1) (match-end 1))) - (filename-base (replace-regexp-in-string ", " "-" filename-str)) + (filename-base (string-replace ", " "-" filename-str)) (top-priorities (string-match "top priorities" bufname)) (diary-items (string-match "diary items" bufname)) (regexp-items (string-match "regexp items" bufname))) diff --git a/lisp/cedet/cedet-files.el b/lisp/cedet/cedet-files.el index c9d557f5974..f540fb5540f 100644 --- a/lisp/cedet/cedet-files.el +++ b/lisp/cedet/cedet-files.el @@ -59,7 +59,7 @@ to the file's truename, and dodging platform tricks." ;; doubling `!'s in the original name... (setq file (subst-char-in-string ?/ ?! - (replace-regexp-in-string "!" "!!" file))) + (string-replace "!" "!!" file))) file)) (defun cedet-file-name-to-directory-name (referencefile &optional testmode) @@ -71,7 +71,7 @@ specific conversions during tests." ;; Replace the ! with / (setq file (subst-char-in-string ?! ?/ file)) ;; Occurrences of // meant there was once a single !. - (setq file (replace-regexp-in-string "//" "!" file)) + (setq file (string-replace "//" "!" file)) ;; Handle Windows special cases (when (or (memq system-type '(windows-nt ms-dos)) testmode) diff --git a/lisp/comint.el b/lisp/comint.el index 40f58f2da7b..7af8e8fd2a5 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -2439,7 +2439,7 @@ carriage returns (\\r) in STRING. This function could be in the list `comint-output-filter-functions'." (when (let ((case-fold-search t)) (string-match comint-password-prompt-regexp - (replace-regexp-in-string "\r" "" string))) + (string-replace "\r" "" string))) (let ((comint--prompt-recursion-depth (1+ comint--prompt-recursion-depth))) (if (> comint--prompt-recursion-depth 10) (message "Password prompt recursion too deep") diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 060f3a84111..72969dd96e2 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -508,7 +508,7 @@ has no effect on MS-Windows." (default (and (stringp modestr) (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr) - (replace-regexp-in-string + (string-replace "-" "" (format "u=%s,g=%s,o=%s" (match-string 1 modestr) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index a7bfae759ed..a990bd3fec3 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -1193,7 +1193,7 @@ NOSELECT the files are merely found but not selected." (interactive) (require 'man) (let* ((file (dired-get-filename)) - (manual-program (replace-regexp-in-string "\\*" "%s" + (manual-program (string-replace "*" "%s" (dired-guess-shell-command "Man command: " (list file))))) (Man-getpage-in-background file))) diff --git a/lisp/dired.el b/lisp/dired.el index 28448be06ce..e577df510ad 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1587,8 +1587,8 @@ see `dired-use-ls-dired' for more details.") ;; because newlines in dirnames are uncommon, and people may ;; have gotten used to seeing unescaped "\" in the headers. ;; Note: adjust dired-build-subdir-alist if you change this. - (setq dir (replace-regexp-in-string "\\\\" "\\\\" dir nil t) - dir (replace-regexp-in-string "\n" "\\n" dir nil t))) + (setq dir (string-replace "\\" "\\\\" dir) + dir (string-replace "\n" "\\n" dir))) ;; If we used --dired and it worked, the lines are already indented. ;; Otherwise, indent them. (unless (save-excursion @@ -3167,15 +3167,15 @@ the quoted forms of those characters. FULL-NAME specifies the actual file name the listing must have, as returned by `dired-get-filename'. LIMIT is the search limit." (let (str) - (setq str (replace-regexp-in-string "\^m" "\\^m" file nil t)) - (setq str (replace-regexp-in-string "\\\\" "\\\\" str nil t)) + (setq str (string-replace "\^m" "\\^m" file)) + (setq str (string-replace "\\" "\\\\" str)) (and (dired-switches-escape-p dired-actual-switches) (string-match-p "[ \t\n]" str) ;; FIXME: to fix this for embedded control characters etc, we ;; should escape everything that `ls -b' does. - (setq str (replace-regexp-in-string " " "\\ " str nil t) - str (replace-regexp-in-string "\t" "\\t" str nil t) - str (replace-regexp-in-string "\n" "\\n" str nil t))) + (setq str (string-replace " " "\\ " str) + str (string-replace "\t" "\\t" str) + str (string-replace "\n" "\\n" str))) (let ((found nil) ;; filenames are preceded by SPC, this makes the search faster ;; (e.g. for the filename "-"). diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index a04413b6f00..ed75bf2bfa9 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -1171,7 +1171,7 @@ clashes." do (aset str j (aref byte 0)) (aset str (1+ j) (aref byte 1)) finally return str)) - (human-readable (replace-regexp-in-string + (human-readable (string-replace "-" "_" orig-name)) (human-readable (replace-regexp-in-string (rx (not (any "0-9a-z_"))) "" human-readable))) diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el index 396949d59a2..aec438ed994 100644 --- a/lisp/emacs-lisp/re-builder.el +++ b/lisp/emacs-lisp/re-builder.el @@ -436,7 +436,7 @@ provided in the Commentary section of this library." (let ((re (with-output-to-string (print (reb-target-binding reb-regexp))))) (setq re (substring re 1 (1- (length re)))) - (setq re (replace-regexp-in-string "\n" "\\n" re nil t)) + (setq re (string-replace "\n" "\\n" re)) (kill-new re) (message "Copied regexp `%s' to kill-ring" re))) diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index 219af3741fa..fcdb8df2032 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -630,8 +630,8 @@ that subcommand." (define-inline erc-dcc-unquote-filename (filename) (inline-quote - (replace-regexp-in-string "\\\\\\\\" "\\" - (replace-regexp-in-string "\\\\\"" "\"" ,filename t t) t t))) + (string-replace "\\\\" "\\" + (string-replace "\\\"" "\"" ,filename)))) (defun erc-dcc-handle-ctcp-send (proc query nick login host to) "This is called if a CTCP DCC SEND subcommand is sent to the client. diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 026c6f84164..c66b03d2e4e 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -3597,7 +3597,7 @@ If S is non-nil, it will be used as the quit reason." If S is non-nil, it will be used as the quit reason." (or s (if (fboundp 'yow) - (replace-regexp-in-string "\n" "" (yow)) + (string-replace "\n" "" (yow)) (erc-quit/part-reason-default)))) (make-obsolete 'erc-quit-reason-zippy "it will be removed." "24.4") @@ -3624,7 +3624,7 @@ If S is non-nil, it will be used as the part reason." If S is non-nil, it will be used as the quit reason." (or s (if (fboundp 'yow) - (replace-regexp-in-string "\n" "" (yow)) + (string-replace "\n" "" (yow)) (erc-quit/part-reason-default)))) (make-obsolete 'erc-part-reason-zippy "it will be removed." "24.4") @@ -6528,7 +6528,7 @@ if `erc-away' is non-nil." (fill-region (point-min) (point-max)) (buffer-string)))) (setq header-line-format - (replace-regexp-in-string + (string-replace "%" "%%" (if face @@ -6804,7 +6804,7 @@ functions." nick user host channel (if (not (string= reason "")) (format ": %s" - (replace-regexp-in-string "%" "%%" reason)) + (string-replace "%" "%%" reason)) ""))))) diff --git a/lisp/files.el b/lisp/files.el index 89ee13eb686..54d0b919e1d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5201,7 +5201,7 @@ The function `find-backup-file-name' also uses this." (expand-file-name (subst-char-in-string ?/ ?! - (replace-regexp-in-string "!" "!!" file)) + (string-replace "!" "!!" file)) backup-directory)) (expand-file-name (file-name-nondirectory file) (file-name-as-directory abs-backup-directory)))))) @@ -6876,7 +6876,7 @@ the resulting file name, and SUFFIX is appended." (file-name-directory result) (subst-char-in-string ?/ ?! - (replace-regexp-in-string + (string-replace "!" "!!" filename)))) (t result)))) (setq result @@ -7989,7 +7989,7 @@ based on existing mode bits, as in \"og+rX-w\"." (default (and (stringp modestr) (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr) - (replace-regexp-in-string + (string-replace "-" "" (format "u=%s,g=%s,o=%s" (match-string 1 modestr) diff --git a/lisp/fringe.el b/lisp/fringe.el index d73aae0459e..82cfacc6b6f 100644 --- a/lisp/fringe.el +++ b/lisp/fringe.el @@ -189,7 +189,7 @@ fringes." :type `(choice ,@ (mapcar (lambda (style) (let ((name - (replace-regexp-in-string "-" " " (car style)))) + (string-replace "-" " " (car style)))) `(const :tag ,(concat (capitalize (substring name 0 1)) (substring name 1)) diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index fb0295d0703..d65e75e44c2 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -8288,7 +8288,7 @@ url is put as the `gnus-button-url' overlay property on the button." ")" (gnus-url-unhex-string (match-string 2 url))))) ((string-match "([^)\"]+)[^\"]+" url) (setq url - (replace-regexp-in-string + (string-replace "\"" "" (replace-regexp-in-string "[\n\t ]+" " " url))) (gnus-info-find-node url)) (t (error "Can't parse %s" url)))) diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index 6202567344f..b1134397e55 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el @@ -2186,7 +2186,7 @@ handle COLLECTION as a list, hash table, or vector." require-match initial-input (or hist 'gnus-group-history) def))) - (replace-regexp-in-string "\n" "" group))) + (string-replace "\n" "" group))) ;;;###autoload (defun gnus-fetch-group (group &optional articles) diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el index 1b2743c1484..56f4fdf6d33 100644 --- a/lisp/gnus/gnus-icalendar.el +++ b/lisp/gnus/gnus-icalendar.el @@ -252,10 +252,10 @@ ;; ugly, but cannot get ;;replace-regexp-in-string work with "\\" as ;;REP, plus we should also handle "\\;" - (replace-regexp-in-string - "\\\\," "," - (replace-regexp-in-string - "\\\\n" "\n" (substring-no-properties value)))))) + (string-replace + "\\," "," + (string-replace + "\\n" "\n" (substring-no-properties value)))))) (accumulate-args (mapping) (cl-destructuring-bind (slot . ical-property) mapping diff --git a/lisp/gnus/gnus-mlspl.el b/lisp/gnus/gnus-mlspl.el index d42f0971259..664027f0164 100644 --- a/lisp/gnus/gnus-mlspl.el +++ b/lisp/gnus/gnus-mlspl.el @@ -209,7 +209,7 @@ Calling (gnus-group-split-fancy nil nil \"mail.others\") returns: "\\)")) ;; Now create the new SPLIT (let ((split-regexp-with-list-ids - (replace-regexp-in-string "@" "[@.]" split-regexp t t)) + (string-replace "@" "[@.]" split-regexp)) (exclude ;; Generate RESTRICTs for SPLIT-EXCLUDEs. (if (listp split-exclude) diff --git a/lisp/gnus/gnus-search.el b/lisp/gnus/gnus-search.el index 8182630dfed..59b8efaa3ac 100644 --- a/lisp/gnus/gnus-search.el +++ b/lisp/gnus/gnus-search.el @@ -572,7 +572,7 @@ nil. If VALUE is a relative time, interpret it as relative to REL-DATE, or (current-time) if REL-DATE is nil." ;; Time parsing doesn't seem to work with slashes. - (let ((value (replace-regexp-in-string "/" "-" value)) + (let ((value (string-replace "/" "-" value)) (now (append '(0 0 0) (seq-subseq (decode-time (or rel-date (current-time))) @@ -1669,7 +1669,7 @@ cross our fingers for the rest of it." Mairix negation requires a \"~\" preceding string search terms, and \"-\" before marks." (let ((next (gnus-search-transform-expression engine (cadr expr)))) - (replace-regexp-in-string + (string-replace ":" (if (eql (caadr expr) 'mark) ":-" @@ -1863,9 +1863,9 @@ Assume \"size\" key is equal to \"larger\"." group (if (file-directory-p (setq group - (replace-regexp-in-string - "\\." "/" - group nil t))) + (string-replace + "." "/" + group))) group)))))) (unless group (signal 'gnus-search-config-error diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el index 44e97d54846..02bbe19e7fe 100644 --- a/lisp/gnus/gnus-start.el +++ b/lisp/gnus/gnus-start.el @@ -854,7 +854,7 @@ If REGEXP is given, lines that match it will be deleted." (goto-char (point-max)) ;; Make sure that each dribble entry is a single line, so that ;; the "remove" code above works. - (insert (replace-regexp-in-string "\n" "\\\\n" string) "\n") + (insert (string-replace "\n" "\\n" string) "\n") (bury-buffer gnus-dribble-buffer) (with-current-buffer gnus-group-buffer (gnus-group-set-mode-line))))) diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 4bdc2023eb4..dc004927b67 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -9191,7 +9191,7 @@ specified by the `gnus-refer-thread-limit' variable." (interactive "sMessage-ID: " gnus-summary-mode) (when (and (stringp message-id) (not (zerop (length message-id)))) - (setq message-id (replace-regexp-in-string " " "" message-id)) + (setq message-id (string-replace " " "" message-id)) ;; Construct the correct Message-ID if necessary. ;; Suggested by tale@pawl.rpi.edu. (unless (string-match "^<" message-id) diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el index be0284515dc..7a5e00c5ec9 100644 --- a/lisp/gnus/gnus-util.el +++ b/lisp/gnus/gnus-util.el @@ -408,7 +408,7 @@ Cache the result as a text property stored in DATE." (defun gnus-mode-string-quote (string) "Quote all \"%\"'s in STRING." - (replace-regexp-in-string "%" "%%" string)) + (string-replace "%" "%%" string)) (defsubst gnus-make-hashtable (&optional size) "Make a hash table of SIZE, testing on `equal'." diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index bcbf7476715..a3ffaec3ff3 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -8599,7 +8599,7 @@ From headers in the original article." (let ((value (message-field-value header))) (dolist (string (mail-header-parse-addresses value 'raw)) (setq string - (replace-regexp-in-string + (string-replace "\n" "" (replace-regexp-in-string "^ +\\| +$" "" string))) (ecomplete-add-item 'mail (car (mail-header-parse-address string)) @@ -8889,7 +8889,7 @@ used to take the screenshot." (defun message-parse-mailto-url (url) "Parse a mailto: url." - (setq url (replace-regexp-in-string "\n" " " url)) + (setq url (string-replace "\n" " " url)) (when (string-match "mailto:/*\\(.*\\)" url) (setq url (substring url (match-beginning 1) nil))) (setq url (if (string-match "^\\?" url) @@ -8931,9 +8931,9 @@ will then start up Emacs ready to compose mail. For emacsclient use (dolist (arg args) (unless (equal (car arg) "body") (message-position-on-field (capitalize (car arg))) - (insert (replace-regexp-in-string + (insert (string-replace "\r\n" "\n" - (mapconcat #'identity (reverse (cdr arg)) ", ") nil t)))) + (mapconcat #'identity (reverse (cdr arg)) ", "))))) (when (assoc "body" args) (message-goto-body) (dolist (body (cdr (assoc "body" args))) diff --git a/lisp/gnus/mml-sec.el b/lisp/gnus/mml-sec.el index 15157e6fbc8..b49793509fc 100644 --- a/lisp/gnus/mml-sec.el +++ b/lisp/gnus/mml-sec.el @@ -1022,7 +1022,7 @@ Returns non-nil if the user has chosen to use SENDER." (if (eq 'OpenPGP protocol) (epg-sign-string context (buffer-string) mode) (epg-sign-string context - (replace-regexp-in-string + (string-replace "\n" "\r\n" (buffer-string)) t)) mml-secure-secret-key-id-list nil) diff --git a/lisp/gnus/mml-smime.el b/lisp/gnus/mml-smime.el index 5c133e680af..959de0902e2 100644 --- a/lisp/gnus/mml-smime.el +++ b/lisp/gnus/mml-smime.el @@ -404,7 +404,7 @@ Content-Disposition: attachment; filename=smime.p7m nil t))))) (mm-sec-error 'gnus-info "Corrupted") (throw 'error handle)) - (setq part (replace-regexp-in-string "\n" "\r\n" part) + (setq part (string-replace "\n" "\r\n" part) context (epg-make-context 'CMS)) (condition-case error ;; (setq plain diff --git a/lisp/gnus/mml2015.el b/lisp/gnus/mml2015.el index 1af7d10d055..8c40fc79f00 100644 --- a/lisp/gnus/mml2015.el +++ b/lisp/gnus/mml2015.el @@ -863,7 +863,7 @@ If set, it overrides the setting of `mml2015-sign-with-sender'." nil t)))) (mm-sec-error 'gnus-info "Corrupted") (throw 'error handle)) - (setq part (replace-regexp-in-string "\n" "\r\n" part) + (setq part (string-replace "\n" "\r\n" part) signature (mm-get-part signature) context (epg-make-context)) (condition-case error diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el index 4867455393a..372df64e2e5 100644 --- a/lisp/gnus/nnmaildir.el +++ b/lisp/gnus/nnmaildir.el @@ -637,13 +637,11 @@ This variable is set by `nnmaildir-request-article'.") (funcall func (cdr entry))))))) (defun nnmaildir--system-name () - (replace-regexp-in-string + (string-replace ":" "\\072" - (replace-regexp-in-string + (string-replace "/" "\\057" - (replace-regexp-in-string "\\\\" "\\134" (system-name) nil 'literal) - nil 'literal) - nil 'literal)) + (string-replace "\\" "\\134" (system-name))))) (defun nnmaildir-request-type (_group &optional _article) 'mail) @@ -937,9 +935,9 @@ This variable is set by `nnmaildir-request-article'.") (setq pgname (nnmaildir--pgname nnmaildir--cur-server gname) ro (nnmaildir--param pgname 'read-only)) - (insert (replace-regexp-in-string + (insert (string-replace " " "\\ " - (nnmaildir--grp-name group) nil t) + (nnmaildir--grp-name group)) " ") (princ (nnmaildir--group-maxnum nnmaildir--cur-server group) nntp-server-buffer) @@ -968,7 +966,7 @@ This variable is set by `nnmaildir-request-article'.") (princ (nnmaildir--group-maxnum nnmaildir--cur-server group) nntp-server-buffer) (insert " " - (replace-regexp-in-string " " "\\ " gname nil t) + (string-replace " " "\\ " gname) "\n"))))) 'group) @@ -1098,7 +1096,7 @@ This variable is set by `nnmaildir-request-article'.") (insert " ") (princ (nnmaildir--group-maxnum nnmaildir--cur-server group) nntp-server-buffer) - (insert " " (replace-regexp-in-string " " "\\ " gname nil t) "\n") + (insert " " (string-replace " " "\\ " gname) "\n") t)))) (defun nnmaildir-request-create-group (gname &optional server _args) @@ -1262,7 +1260,7 @@ This variable is set by `nnmaildir-request-article'.") (insert "\t" (nnmaildir--nov-get-beg nov) "\t" (nnmaildir--art-msgid article) "\t" (nnmaildir--nov-get-mid nov) "\tXref: nnmaildir " - (replace-regexp-in-string " " "\\ " gname nil t) ":") + (string-replace " " "\\ " gname) ":") (princ num nntp-server-buffer) (insert "\t" (nnmaildir--nov-get-end nov) "\n")))) (catch 'return diff --git a/lisp/gnus/nnrss.el b/lisp/gnus/nnrss.el index a40fa88631f..8cd8cbe84f1 100644 --- a/lisp/gnus/nnrss.el +++ b/lisp/gnus/nnrss.el @@ -785,7 +785,7 @@ It is useful when `(setq nnrss-use-local t)'." (nnrss-node-just-text node) node)) (cleaned-text (if text - (replace-regexp-in-string + (string-replace "\r\n" "\n" (replace-regexp-in-string "^[\000-\037\177]+\\|^ +\\| +$" "" diff --git a/lisp/gnus/spam-report.el b/lisp/gnus/spam-report.el index a4234f84001..5fa280ea058 100644 --- a/lisp/gnus/spam-report.el +++ b/lisp/gnus/spam-report.el @@ -159,7 +159,7 @@ submitted at once. Internal variable.") rpt-host (concat "/" - (replace-regexp-in-string + (string-replace "/" ":" (replace-regexp-in-string "^.*article.gmane.org/" "" @@ -224,7 +224,7 @@ the function specified by `spam-report-url-ping-function'." (defcustom spam-report-user-mail-address (and (stringp user-mail-address) - (replace-regexp-in-string "@" "" user-mail-address)) + (string-replace "@" "" user-mail-address)) "Mail address of this user used for spam reports to Gmane. This is initialized based on `user-mail-address'." :type '(choice string diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 9088f31053b..6c0180590b9 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el @@ -1719,7 +1719,7 @@ If point is on a group name, this function operates on that group." (ibuffer-buffer-name-face buffer mark)))) (if (not (seq-position string ?\n)) string - (replace-regexp-in-string + (string-replace "\n" (propertize "^J" 'font-lock-face 'escape-glyph) string)))) (define-ibuffer-column size diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 2509ecf8f82..74985b9e56d 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -704,7 +704,7 @@ Increase at own risk.") (thumb (cdr (assq ?t spec)))) (rename-file nq8 thumb t))) (message "command %S %s" (process-command process) - (replace-regexp-in-string "\n" "" status))))) + (string-replace "\n" "" status))))) process)) (defun image-dired-pngcrush-thumb (spec) @@ -726,7 +726,7 @@ Increase at own risk.") (unless (and (eq (process-status process) 'exit) (zerop (process-exit-status process))) (message "command %S %s" (process-command process) - (replace-regexp-in-string "\n" "" status))) + (string-replace "\n" "" status))) (when (memq (process-status process) '(exit signal)) (let ((temp (cdr (assq ?q spec)))) (delete-file temp))))) @@ -744,7 +744,7 @@ Increase at own risk.") (unless (and (eq (process-status process) 'exit) (zerop (process-exit-status process))) (message "command %S %s" (process-command process) - (replace-regexp-in-string "\n" "" status))))) + (string-replace "\n" "" status))))) process)) (defun image-dired-create-thumb-1 (original-file thumbnail-file) @@ -794,7 +794,7 @@ Increase at own risk.") (zerop (process-exit-status process)))) (message "Thumb could not be created for %s: %s" (abbreviate-file-name original-file) - (replace-regexp-in-string "\n" "" status)) + (string-replace "\n" "" status)) (set-file-modes thumbnail-file #o600) (clear-image-cache thumbnail-file) ;; PNG thumbnail has been created since we are diff --git a/lisp/info.el b/lisp/info.el index b65728ba41b..1c477a7082f 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -1732,14 +1732,14 @@ escaped (\\\",\\\\)." (concat " (" (if (stringp Info-current-file) - (replace-regexp-in-string + (string-replace "%" "%%" (file-name-sans-extension (file-name-nondirectory Info-current-file))) (format "*%S*" Info-current-file)) ") " (if Info-current-node - (propertize (replace-regexp-in-string + (propertize (string-replace "%" "%%" Info-current-node) 'face 'mode-line-buffer-id 'help-echo diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 55accf5beee..71e2653ffe9 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -2166,7 +2166,7 @@ See `set-language-info-alist' for use in programs." (let ((str (eval (get-language-info language-name 'sample-text)))) (if (stringp str) (insert "Sample text:\n " - (replace-regexp-in-string "\n" "\n " str) + (string-replace "\n" "\n " str) "\n\n"))) (error nil)) (let ((input-method (get-language-info language-name 'input-method)) diff --git a/lisp/mail/rfc2231.el b/lisp/mail/rfc2231.el index 6fb4502b23b..db34fd2cb9e 100644 --- a/lisp/mail/rfc2231.el +++ b/lisp/mail/rfc2231.el @@ -63,7 +63,7 @@ must never cause a Lisp error." (let (mod) (when (and (string-match "\\\\\"" string) (not (string-match "\\`\"\\|[^\\]\"" string))) - (setq string (replace-regexp-in-string "\\\\\"" "\"" string) + (setq string (string-replace "\\\"" "\"" string) mod t)) (when (and (string-match "\\\\(" string) (string-match "\\\\)" string) diff --git a/lisp/mail/rfc2368.el b/lisp/mail/rfc2368.el index 553f3cc3a54..b96f15d3e68 100644 --- a/lisp/mail/rfc2368.el +++ b/lisp/mail/rfc2368.el @@ -91,7 +91,7 @@ Note: make sure MAILTO-URL has been \"unhtmlized\" (e.g., & -> &), before calling this function." (let ((case-fold-search t) prequery query headers-alist) - (setq mailto-url (replace-regexp-in-string "\n" " " mailto-url)) + (setq mailto-url (string-replace "\n" " " mailto-url)) (if (string-match rfc2368-mailto-regexp mailto-url) (progn (setq prequery diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index e479a8e9b4a..8a38337773e 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -1960,7 +1960,7 @@ Value is the size of the newly read mail after conversion." (file-name-nondirectory (if (memq system-type '(windows-nt cygwin ms-dos)) ;; cannot have colons in file name - (replace-regexp-in-string ":" "-" file) + (string-replace ":" "-" file) file))) ;; Use the directory of this rmail file ;; because it's a nuisance to use the homedir @@ -3374,7 +3374,7 @@ The idea is to match it against simplified subjects of other messages." ;; Hide commas so it will work ok if parsed as a comma-separated list ;; of regexps. (setq subject - (replace-regexp-in-string "," "\054" subject t t)) + (string-replace "," "\054" subject)) (concat "\\`" subject "\\'"))) (defun rmail-next-same-subject (n) diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el index eb8590f1f73..4c23686909c 100644 --- a/lisp/mail/rmailout.el +++ b/lisp/mail/rmailout.el @@ -678,9 +678,9 @@ than appending to it. Deletes the message after writing if (or (mail-fetch-field "Subject") rmail-default-body-file))) (setq default-file - (replace-regexp-in-string ":" "-" default-file)) + (string-replace ":" "-" default-file)) (setq default-file - (replace-regexp-in-string " " "-" default-file)) + (string-replace " " "-" default-file)) (list (setq rmail-default-body-file (read-file-name "Output message body to file: " diff --git a/lisp/mail/undigest.el b/lisp/mail/undigest.el index bf57ed6fa6f..0760a477296 100644 --- a/lisp/mail/undigest.el +++ b/lisp/mail/undigest.el @@ -125,7 +125,7 @@ See rmail-digest-methods." ;; Undo masking of separators inside digestified messages (goto-char (point-min)) (while (search-forward - (replace-regexp-in-string "\n-" "\n " separator) nil t) + (string-replace "\n-" "\n " separator) nil t) (replace-match separator)) ;; Return the list of marker pairs (nreverse result)))))) diff --git a/lisp/man.el b/lisp/man.el index 9b941a2b3d2..54b6ffe9836 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -802,7 +802,7 @@ POS defaults to `point'." ;; added by troff, and remove it. (or (not (eq (string-to-char (substring 1st-part -1)) ?-)) (string-match-p "-" (substring 1st-part 0 -1)) - (setq word (replace-regexp-in-string "-" "" word)))) + (setq word (string-replace "-" "" word)))) ;; Make sure the section number gets included by the code below. (goto-char (match-end 1))) (when (string-match "[-._‐]+$" word) diff --git a/lisp/mouse.el b/lisp/mouse.el index 89e5d7c48a3..cf7c17be28f 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -180,7 +180,7 @@ items `Turn Off' and `Help'." `(keymap ,(format "%s - %s" indicator (capitalize - (replace-regexp-in-string + (string-replace "-" " " (format "%S" minor-mode)))) (turn-off menu-item "Turn off minor mode" ,mm-fun) (help menu-item "Help for minor mode" diff --git a/lisp/mpc.el b/lisp/mpc.el index ab572aa539a..e04ffa49747 100644 --- a/lisp/mpc.el +++ b/lisp/mpc.el @@ -214,8 +214,8 @@ defaults to 6600 and HOST defaults to localhost." (with-current-buffer "*MPC-debug*" (goto-char (point-max)) (insert-before-markers ;So it scrolls. - (replace-regexp-in-string "\n" "\n " - (apply #'format-message format args)) + (string-replace "\n" "\n " + (apply #'format-message format args)) "\n")))) (defun mpc--proc-filter (proc string) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 6d64100be17..f739cd72cc3 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -1644,7 +1644,7 @@ used instead of `browse-url-new-window-flag'." (insert "\n")) (goto-char (prog1 (point) - (insert (replace-regexp-in-string "\r\n" "\n" body)) + (insert (string-replace "\r\n" "\n" body)) (unless (bolp) (insert "\n")))))))) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index eec3ec7ba8b..2a81d2e0c8c 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -779,7 +779,7 @@ Currently this means either text/html or application/xhtml+xml." (propertize "...: " 'face 'variable-pitch)))) (propertize "..." 'face 'variable-pitch))))))) - (replace-regexp-in-string + (string-replace "%" "%%" (format-spec eww-header-line-format diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el index e623dab26df..dc541943587 100644 --- a/lisp/net/newst-backend.el +++ b/lisp/net/newst-backend.el @@ -610,7 +610,7 @@ This does NOT start the retrieval timers." (interactive) (let ((filename (read-string "Filename: " (concat feed ":_" - (replace-regexp-in-string + (string-replace " " "_" (newsticker--title item)) ".html")))) (with-temp-buffer diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index f11f36e8096..e7aec505b0b 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -800,7 +800,7 @@ When 0, do not auto-reconnect." (defun rcirc-sentinel (process sentinel) "Called when PROCESS receives SENTINEL." - (let ((sentinel (replace-regexp-in-string "\n" "" sentinel))) + (let ((sentinel (string-replace "\n" "" sentinel))) (rcirc-debug process (format "SENTINEL: %S %S\n" process sentinel)) (with-rcirc-process-buffer process (dolist (buffer (cons nil (mapcar 'cdr rcirc-buffer-alist))) diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el index 821ef4af8e0..f5480afb698 100644 --- a/lisp/net/soap-client.el +++ b/lisp/net/soap-client.el @@ -659,7 +659,7 @@ representing leap seconds." (if second (if second-fraction (let* ((second-fraction-significand - (replace-regexp-in-string "\\." "" second-fraction)) + (string-replace "." "" second-fraction)) (hertz (expt 10 (length second-fraction-significand))) (ticks (+ (* hertz (string-to-number second)) diff --git a/lisp/nxml/rng-cmpct.el b/lisp/nxml/rng-cmpct.el index 1314ade9e31..d820d1b99b5 100644 --- a/lisp/nxml/rng-cmpct.el +++ b/lisp/nxml/rng-cmpct.el @@ -100,7 +100,7 @@ Return a pattern." "Regular expression to match a single-quoted literal.") (defconst rng-c-literal-2-re - (replace-regexp-in-string "'" "\"" rng-c-literal-1-re) + (string-replace "'" "\"" rng-c-literal-1-re) "Regular expression to match a double-quoted literal.") (defconst rng-c-ncname-re "\\w+") diff --git a/lisp/nxml/xmltok.el b/lisp/nxml/xmltok.el index 9824eebbd8b..38bc2e141e6 100644 --- a/lisp/nxml/xmltok.el +++ b/lisp/nxml/xmltok.el @@ -479,7 +479,7 @@ and VALUE-END, otherwise a STRING giving the value." "[^<'&\r\n\t]*" (xmltok-g complex1 "[&\r\n\t][^<']*") opt "'")) - (lit2 (cons (replace-regexp-in-string "'" "\"" (car lit1)) + (lit2 (cons (string-replace "'" "\"" (car lit1)) '(complex2))) (literal (xmltok-g literal lit1 or lit2)) (name (xmltok+ open (xmltok-g xmlns "xmlns") or ncname close diff --git a/lisp/obsolete/nnir.el b/lisp/obsolete/nnir.el index 40a8ec57b98..caeca988810 100644 --- a/lisp/obsolete/nnir.el +++ b/lisp/obsolete/nnir.el @@ -920,10 +920,10 @@ Tested with swish-e-2.0.1 on Windows NT 4.0." ;; eliminate all ".", "/", "\" from beginning. Always matches. (string-match "^[./\\]*\\(.*\\)$" dirnam) ;; "/" -> "." - (setq group (replace-regexp-in-string + (setq group (string-replace "/" "." (match-string 1 dirnam))) ;; Windows "\\" -> "." - (setq group (replace-regexp-in-string "\\\\" "." group)) + (setq group (string-replace "\\" "." group)) (push (vector (gnus-group-full-name group server) (string-to-number artno) @@ -996,7 +996,7 @@ Tested with swish-e-2.0.1 on Windows NT 4.0." (when (string-match prefix dirnam) (setq dirnam (replace-match "" t t dirnam))) (push (vector (gnus-group-full-name - (replace-regexp-in-string "/" "." dirnam) server) + (string-replace "/" "." dirnam) server) (string-to-number artno) (string-to-number score)) artlist)) @@ -1205,9 +1205,9 @@ construct path: search terms (see the variable group (if (file-directory-p (setq group - (replace-regexp-in-string - "\\." "/" - group nil t))) + (string-replace + "." "/" + group))) group)))))) (unless group (error "Cannot locate directory for group")) diff --git a/lisp/play/dunnet.el b/lisp/play/dunnet.el index c3be029a658..3bb8bf0c82b 100644 --- a/lisp/play/dunnet.el +++ b/lisp/play/dunnet.el @@ -2373,7 +2373,7 @@ Also prints current score to let user know he has scored." (dun-mprincl "Incorrect."))) (let (varname epoint afterq i value) - (setq varname (replace-regexp-in-string " " "" (substring line 0 esign))) + (setq varname (string-replace " " "" (substring line 0 esign))) (if (or (= (length varname) 0) (< (- (length line) esign) 2)) (progn diff --git a/lisp/play/handwrite.el b/lisp/play/handwrite.el index cc058230751..2aec408e11b 100644 --- a/lisp/play/handwrite.el +++ b/lisp/play/handwrite.el @@ -200,7 +200,7 @@ Variables: `handwrite-linespace' (default 12) (concat "\\\\" (cdr trans)) line))) (switch-to-buffer ps-buf-name) - (insert (replace-regexp-in-string "\n" "" line)) + (insert (string-replace "\n" "" line)) (message "write write write...") (setq ps-ypos (+ ps-ypos handwrite-linespace)) (end-of-line) diff --git a/lisp/proced.el b/lisp/proced.el index d1a243df8e0..2fafdcc58e5 100644 --- a/lisp/proced.el +++ b/lisp/proced.el @@ -1389,7 +1389,7 @@ The return string is always 6 characters wide." (defun proced-format-args (args) "Format attribute ARGS. Replace newline characters by \"^J\" (two characters)." - (replace-regexp-in-string "\n" "^J" args)) + (string-replace "\n" "^J" args)) (defun proced-format (process-alist format) "Display PROCESS-ALIST using FORMAT." diff --git a/lisp/profiler.el b/lisp/profiler.el index 8145e51d75d..4c427692cb8 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -499,7 +499,7 @@ RET: expand or collapse")) (defun profiler-report-header-line-format (fmt &rest args) (let* ((header (apply #'profiler-format fmt args)) - (escaped (replace-regexp-in-string "%" "%%" header))) + (escaped (string-replace "%" "%%" header))) (concat (propertize " " 'display '(space :align-to 0) diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index b9c8305bed0..97596d0d278 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1963,7 +1963,7 @@ commands to be prefixed by \"-interpreter-exec console\".") The string is enclosed in double quotes. All embedded quotes, newlines, and backslashes are preceded with a backslash." (setq string (replace-regexp-in-string "\\([\"\\]\\)" "\\\\\\&" string)) - (setq string (replace-regexp-in-string "\n" "\\n" string t t)) + (setq string (string-replace "\n" "\\n" string)) (concat "\"" string "\"")) (defun gdb-input (command handler-function &optional trigger-name) diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el index 4d277755aeb..df17b87c013 100644 --- a/lisp/progmodes/make-mode.el +++ b/lisp/progmodes/make-mode.el @@ -257,7 +257,7 @@ not be enclosed in { } or ( )." "Regex used to highlight makepp rule action lines in font lock mode.") (defconst makefile-bsdmake-rule-action-regex - (replace-regexp-in-string "-@" "-+@" makefile-rule-action-regex) + (string-replace "-@" "-+@" makefile-rule-action-regex) "Regex used to highlight BSD rule action lines in font lock mode.") ;; Note that the first and second subexpression is used by font lock. Note @@ -358,11 +358,10 @@ not be enclosed in { } or ( )." ,@(if keywords ;; Fontify conditionals and includes. `((,(concat "^\\(?: [ \t]*\\)?" - (replace-regexp-in-string + (string-replace " " "[ \t]+" (if (eq (car keywords) t) - (replace-regexp-in-string "-" "[_-]" - (regexp-opt (cdr keywords) t)) + (string-replace "-" "[_-]" (regexp-opt (cdr keywords) t)) (regexp-opt keywords t))) "\\>[ \t]*\\([^: \t\n#]*\\)") (1 font-lock-keyword-face) (2 font-lock-variable-name-face)))) diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el index 0b520e39074..2e23c2e2cab 100644 --- a/lisp/progmodes/prolog.el +++ b/lisp/progmodes/prolog.el @@ -2277,7 +2277,7 @@ between them)." ;(goto-char beg) (if (search-forward-regexp "^[ \t]*\\(%+\\|\\*+\\|/\\*+\\)[ \t]*" end t) - (replace-regexp-in-string "/" " " (buffer-substring beg (point))) + (string-replace "/" " " (buffer-substring beg (point))) (beginning-of-line) (when (search-forward-regexp "^[ \t]+" end t) (buffer-substring beg (point))))))))) diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 01fb044161b..74b48ca4bde 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1788,8 +1788,8 @@ If the result is do-end block, it will always be multiline." (buffer-substring-no-properties (1+ min) (1- max)))) (setq content (if (equal string-quote "'") - (replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)'" "\\1\\\\'" content)) - (replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)\"" "\\1\\\\\"" content)))) + (string-replace "\\\"" "\"" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)'" "\\1\\\\'" content)) + (string-replace "\\'" "'" (replace-regexp-in-string "\\(\\`\\|[^\\]\\)\"" "\\1\\\\\"" content)))) (let ((orig-point (point))) (delete-region min max) (insert diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index f144549cf6d..b9012166a52 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -3843,7 +3843,7 @@ to avoid deleting non-prompt output." (defun sql-remove-tabs-filter (str) "Replace tab characters with spaces." - (replace-regexp-in-string "\t" " " str nil t)) + (string-replace "\t" " " str)) (defun sql-toggle-pop-to-buffer-after-send-region (&optional value) "Toggle `sql-pop-to-buffer-after-send-region'. @@ -3864,7 +3864,7 @@ If given the optional parameter VALUE, sets "If non-nil, display messages related to the use of redirection.") (defun sql-str-literal (s) - (concat "'" (replace-regexp-in-string "[']" "''" s) "'")) + (concat "'" (string-replace "[']" "''" s) "'")) (defun sql-redirect (sqlbuf command &optional outbuf save-prior) "Execute the SQL command and send output to OUTBUF. diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 02a8d72758c..eb170baa5d8 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -175,7 +175,7 @@ and you want to simplify them for the mode line (defvar which-func-table (make-hash-table :test 'eq :weakness 'key)) (defconst which-func-current - '(:eval (replace-regexp-in-string + '(:eval (string-replace "%" "%%" (or (gethash (selected-window) which-func-table) which-func-unknown)))) diff --git a/lisp/replace.el b/lisp/replace.el index ee46286a75f..c67877efd5d 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -213,7 +213,7 @@ wants to replace FROM with TO." (when query-replace-from-to-separator ;; Check if the first non-whitespace char is displayable (if (char-displayable-p - (string-to-char (replace-regexp-in-string + (string-to-char (string-replace " " "" query-replace-from-to-separator))) query-replace-from-to-separator " -> "))) @@ -2101,7 +2101,7 @@ See also `multi-occur'." ;; Add non-numeric prefix to all non-first lines ;; of multi-line matches. (concat - (replace-regexp-in-string + (string-replace "\n" (if prefix-face (propertize @@ -2506,12 +2506,10 @@ a string, it is first passed through `prin1-to-string' with the `noescape' argument set. `match-data' is preserved across the call." - (save-match-data - (replace-regexp-in-string "\\\\" "\\\\" - (if (stringp replacement) - replacement - (prin1-to-string replacement t)) - t t))) + (string-replace "\\" "\\\\" + (if (stringp replacement) + replacement + (prin1-to-string replacement t)))) (defun replace-loop-through-replacements (data count) ;; DATA is a vector containing the following values: diff --git a/lisp/select.el b/lisp/select.el index eaa74cebd80..15e171c13f9 100644 --- a/lisp/select.el +++ b/lisp/select.el @@ -496,7 +496,7 @@ two markers or an overlay. Otherwise, it is nil." (error "Unknown selection type: %S" type))))) ;; Most programs are unable to handle NUL bytes in strings. - (setq str (replace-regexp-in-string "\0" "\\0" str t t)) + (setq str (string-replace "\0" "\\0" str)) (setq next-selection-coding-system nil) (cons type str)))) diff --git a/lisp/ses.el b/lisp/ses.el index ca515f829dc..81c27144a54 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -3357,7 +3357,7 @@ is non-nil. Newlines and tabs in the export text are escaped." (push "'" result) (setq item (cadr item))) (setq item (ses-prin1 item)) - (setq item (replace-regexp-in-string "\t" "\\\\t" item)) + (setq item (string-replace "\t" "\\t" item)) (push item result) (cond ((< col maxcol) diff --git a/lisp/subr.el b/lisp/subr.el index b8286600664..87298b5cfde 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3681,7 +3681,7 @@ See Info node `(elisp)Security Considerations'." "''" ;; Quote everything except POSIX filename characters. ;; This should be safe enough even for really weird shells. - (replace-regexp-in-string + (string-replace "\n" "'\n'" (replace-regexp-in-string "[^-0-9a-zA-Z_./\n]" "\\\\\\&" argument)))) )) diff --git a/lisp/term/pc-win.el b/lisp/term/pc-win.el index 8cff2ceaeec..9e7b360b9c6 100644 --- a/lisp/term/pc-win.el +++ b/lisp/term/pc-win.el @@ -290,7 +290,7 @@ This is used by `msdos-show-help'.") (not cursor-in-echo-area)) ;Don't overwrite a prompt. (cond ((stringp help) - (setq help (replace-regexp-in-string "\n" ", " help)) + (setq help (string-replace "\n" ", " help)) (unless (or msdos-previous-message (string-equal help (current-message)) (and (stringp msdos-last-help-message) diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el index 6b849164aec..80afcb36040 100644 --- a/lisp/term/w32-win.el +++ b/lisp/term/w32-win.el @@ -410,7 +410,7 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") ;;; Fix interface to (X-specific) mouse.el (defun w32--set-selection (type value) (if (eq type 'CLIPBOARD) - (w32-set-clipboard-data (replace-regexp-in-string "\0" "\\0" value t t)) + (w32-set-clipboard-data (string-replace "\0" "\\0" value)) (put 'x-selections (or type 'PRIMARY) value))) (defun w32--get-selection (&optional type data-type) diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index 8bcae37afe4..868b33ea9c5 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -1015,10 +1015,9 @@ hitting screen's max DCS length." 'terminal-init-screen)) (bytes (encode-coding-string data 'utf-8-unix)) (base-64 (if screen - (replace-regexp-in-string + (string-replace "\n" "\e\\\eP" - (base64-encode-string bytes) - :fixedcase :literal) + (base64-encode-string bytes)) (base64-encode-string bytes :no-line-break))) (length (length base-64))) (if (> length xterm-max-cut-length) diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el index 1368af01bac..1d5d1caeabc 100644 --- a/lisp/textmodes/picture.el +++ b/lisp/textmodes/picture.el @@ -449,8 +449,8 @@ If no such character is found, move to beginning of line." (progn (beginning-of-line) (skip-chars-backward - (concat "^" (replace-regexp-in-string - "\\\\" "\\\\" picture-tab-chars nil t)) + (concat "^" (string-replace + "\\" "\\\\" picture-tab-chars)) (point-min)) (not (bobp)))) (move-to-column target)) diff --git a/lisp/thumbs.el b/lisp/thumbs.el index 5710b8c353b..4c863883ba4 100644 --- a/lisp/thumbs.el +++ b/lisp/thumbs.el @@ -434,10 +434,10 @@ Open another window." (defun thumbs-call-setroot-command (img) "Call the setroot program for IMG." (run-hooks 'thumbs-before-setroot-hook) - (shell-command (replace-regexp-in-string - "\\*" + (shell-command (string-replace + "*" (shell-quote-argument (expand-file-name img)) - thumbs-setroot-command nil t)) + thumbs-setroot-command)) (run-hooks 'thumbs-after-setroot-hook)) (defun thumbs-set-image-at-point-to-root-window () diff --git a/lisp/tooltip.el b/lisp/tooltip.el index 03d9f54ea6c..23b67ee2cab 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el @@ -346,7 +346,7 @@ It is also called if Tooltip mode is on, for text-only displays." (not cursor-in-echo-area)) ;Don't overwrite a prompt. (cond ((stringp help) - (setq help (replace-regexp-in-string "\n" ", " help)) + (setq help (string-replace "\n" ", " help)) (unless (or tooltip-previous-message (equal-including-properties help (current-message)) (and (stringp tooltip-help-message) diff --git a/lisp/transient.el b/lisp/transient.el index 5f66a13094b..4087a0c68a6 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -3064,18 +3064,18 @@ Optional support for popup buttons is also implemented here." ((equal (seq-take seq len) transient--redisplay-key) (let ((pre (key-description (vconcat (seq-take seq len)))) (suf (key-description (vconcat (seq-drop seq len))))) - (setq pre (replace-regexp-in-string "RET" "C-m" pre t)) - (setq pre (replace-regexp-in-string "TAB" "C-i" pre t)) - (setq suf (replace-regexp-in-string "RET" "C-m" suf t)) - (setq suf (replace-regexp-in-string "TAB" "C-i" suf t)) + (setq pre (string-replace "RET" "C-m" pre)) + (setq pre (string-replace "TAB" "C-i" pre)) + (setq suf (string-replace "RET" "C-m" suf)) + (setq suf (string-replace "TAB" "C-i" suf)) ;; We use e.g. "-k" instead of the more correct "- k", ;; because the former is prettier. If we did that in ;; the definition, then we want to drop the space that ;; is reinserted above. False-positives are possible ;; for silly bindings like "-C-c C-c". (unless (string-match-p " " key) - (setq pre (replace-regexp-in-string " " "" pre)) - (setq suf (replace-regexp-in-string " " "" suf))) + (setq pre (string-replace " " "" pre)) + (setq suf (string-replace " " "" suf))) (concat (propertize pre 'face 'default) (and (string-prefix-p (concat pre " ") key) " ") (transient--colorize-key suf cmd) diff --git a/lisp/url/url-mailto.el b/lisp/url/url-mailto.el index 29c2780121a..4fd631d2955 100644 --- a/lisp/url/url-mailto.el +++ b/lisp/url/url-mailto.el @@ -105,7 +105,7 @@ (goto-char (point-max))) (insert (mapconcat (lambda (string) - (replace-regexp-in-string "\r\n" "\n" string)) + (string-replace "\r\n" "\n" string)) (cdar args) "\n"))) (url-mail-goto-field (caar args)) ;; (setq func (intern-soft (concat "mail-" (caar args)))) diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index 4a44787bb03..46e9c97eb0a 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el @@ -974,8 +974,8 @@ Return non-nil if it is." (not (looking-at (format ".+ .+ <%s>" (regexp-quote mail)))) (looking-at ".+ \\(.+ <.+>\\) *\\((tiny change)\\)?")) - (let ((author (replace-regexp-in-string " " " " - (match-string 1)))) + (let ((author (string-replace " " " " + (match-string 1)))) (unless (and log-edit-author (string-match (regexp-quote author) (car log-edit-author))) diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index de5a90dc602..5144b5d0bbb 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el @@ -467,7 +467,7 @@ in the branch repository (or whose status not be determined)." ;; Erase the status text that matched. (delete-region (match-beginning 0) (match-end 0)) (setq status - (intern (replace-regexp-in-string " " "" statusword))))) + (intern (string-replace " " "" statusword))))) (when status (goto-char (point-min)) (skip-chars-forward " \n\t") ;Throw away spaces. diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index c9c1e91d483..4a64caa36b8 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -851,8 +851,8 @@ if we don't understand a construct, we signal (push "\\[" parts)) (t (let ((x (substring glob i j))) - (setf x (replace-regexp-in-string - "\\\\" "\\\\" x t t)) + (setf x (string-replace + "\\" "\\\\" x)) (setf i (1+ j)) (cond ((eq (aref x 0) ?!) (setf (aref x 0) ?^)) diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el index c30920dd157..544a6c769fc 100644 --- a/lisp/vc/vc-svn.el +++ b/lisp/vc/vc-svn.el @@ -192,7 +192,7 @@ switches." (let ((state (cdr (assq (aref (match-string 1) 0) state-map))) (propstat (cdr (assq (aref (match-string 2) 0) state-map))) (filename (if (memq system-type '(windows-nt ms-dos)) - (replace-regexp-in-string "\\\\" "/" (match-string 4)) + (string-replace "\\" "/" (match-string 4)) (match-string 4)))) (and (memq propstat '(conflict edited)) (not (eq state 'conflict)) ; conflict always wins diff --git a/lisp/xdg.el b/lisp/xdg.el index 0bdfd114c48..e5165bbd86a 100644 --- a/lisp/xdg.el +++ b/lisp/xdg.el @@ -208,8 +208,8 @@ Optional argument GROUP defaults to the string \"Desktop Entry\"." "Partition VALUE into elements delimited by unescaped semicolons." (let (res) (setq value (string-trim-left value)) - (dolist (x (split-string (replace-regexp-in-string "\\\\;" "\0" value) ";")) - (push (replace-regexp-in-string "\0" ";" x) res)) + (dolist (x (split-string (string-replace "\\;" "\0" value) ";")) + (push (string-replace "\0" ";" x) res)) (when (null (string-match-p "[^[:blank:]]" (car res))) (pop res)) (nreverse res))) diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 235c02f8e8b..ea856ab311c 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el @@ -146,7 +146,7 @@ The buffer's contents should %s: "") char (if (string= fixture expected-string) "stay" "become") - (replace-regexp-in-string "\n" "\\\\n" expected-string) + (string-replace "\n" "\\n" expected-string) expected-point))) `(ert-deftest ,(intern (format "electric-pair-%s-at-point-%s-in-%s%s" name diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el index 503cb5d7aab..50ac370b5b5 100644 --- a/test/lisp/term-tests.el +++ b/test/lisp/term-tests.el @@ -56,7 +56,7 @@ first line\r next line\r\n")) (should (equal (term-test-screen-from-input 40 12 str) - (replace-regexp-in-string "\r" "" str))))) + (string-replace "\r" "" str))))) (ert-deftest term-carriage-return () (skip-unless (not (memq system-type '(windows-nt ms-dos)))) diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el index 0d64320496d..4e6fbbba923 100644 --- a/test/lisp/time-stamp-tests.el +++ b/test/lisp/time-stamp-tests.el @@ -849,7 +849,7 @@ The functions in `pattern-mod' are composed left to right." (defun formatz-mod-del-colons (string) "Returns STRING with any colons removed." - (replace-regexp-in-string ":" "" string)) + (string-replace ":" "" string)) (defun formatz-mod-add-00 (string) "Returns STRING with \"00\" appended." diff --git a/test/lisp/wdired-tests.el b/test/lisp/wdired-tests.el index ba276e24d96..96a01fc2c7b 100644 --- a/test/lisp/wdired-tests.el +++ b/test/lisp/wdired-tests.el @@ -31,7 +31,7 @@ Partially modifying a file name should succeed." (let* ((test-dir (make-temp-file "test-dir-" t)) (test-file (concat (file-name-as-directory test-dir) "foo.c")) (replace "bar") - (new-file (replace-regexp-in-string "foo" replace test-file)) + (new-file (string-replace "foo" replace test-file)) (wdired-use-interactive-rename t)) (write-region "" nil test-file nil 'silent) (advice-add 'dired-query ; Don't ask confirmation to overwrite a file. @@ -109,7 +109,7 @@ wdired-mode." (let* ((test-dir (make-temp-file "test-dir-" t)) (test-file (concat (file-name-as-directory test-dir) "foo.c")) (replace "bar") - (new-file (replace-regexp-in-string "foo" replace test-file))) + (new-file (string-replace "foo" replace test-file))) (write-region "" nil test-file nil 'silent) (let ((buf (find-file-noselect test-dir))) (unwind-protect diff --git a/test/src/json-tests.el b/test/src/json-tests.el index 908945fcb08..8dc0a744aa0 100644 --- a/test/src/json-tests.el +++ b/test/src/json-tests.el @@ -252,7 +252,7 @@ Test with both unibyte and multibyte strings." (let* ((input "{ \"abc\" : [9, false] , \"def\" : null }") (output - (replace-regexp-in-string " " "" input))) + (string-replace " " "" input))) (should (equal (json-parse-string input :object-type 'plist :null-object :json-null -- cgit v1.2.3 From d9eac0b4263c10b2ab3a428cf8faa4b5e1d99a83 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 15 Aug 2021 19:27:06 +0300 Subject: Use map-keymap in context-menu-global, context-menu-local, context-menu-minor --- lisp/mouse.el | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 1f5bd8e4a6b..42154255475 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -317,22 +317,24 @@ the same menu with changes such as added new menu items." "Global submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-global] menu-bar-separator) - (dolist (item (lookup-key global-map [menu-bar])) - (when (and (consp item) (consp (cdr item))) - (define-key-after menu (vector (car item)) - (copy-sequence (cdr item))))) + (map-keymap (lambda (key binding) + (when (consp binding) + (define-key-after menu (vector key) + (copy-sequence binding)))) + (lookup-key global-map [menu-bar])) menu) (defun context-menu-local (menu) "Major mode submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-local] menu-bar-separator) - (dolist (item (local-key-binding [menu-bar])) - (when (and (consp item) (consp (cdr item))) - ;; Fix deep menu created by `imenu-add-to-menubar'. - (when (eq (car item) 'keymap) (setq item (cadr item))) - (define-key-after menu (vector (car item)) - (copy-sequence (cdr item))))) + (let ((keymap (local-key-binding [menu-bar]))) + (when keymap + (map-keymap (lambda (key binding) + (when (consp binding) + (define-key-after menu (vector key) + (copy-sequence binding)))) + keymap))) menu) (defun context-menu-minor (menu) @@ -341,10 +343,11 @@ the same menu with changes such as added new menu items." (define-key-after menu [separator-minor] menu-bar-separator) (dolist (mode (minor-mode-key-binding [menu-bar])) (when (and (consp mode) (symbol-value (car mode))) - (dolist (item (cdr mode)) - (when (and (consp item) (consp (cdr item))) - (define-key-after menu (vector (car item)) - (copy-sequence (cdr item))))))) + (map-keymap (lambda (key binding) + (when (consp binding) + (define-key-after menu (vector key) + (copy-sequence binding)))) + (cdr mode)))) menu) (defun context-menu-vc (menu) -- cgit v1.2.3 From ca781e4430bb817ad4918644ef45814de71e5927 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Tue, 17 Aug 2021 11:31:09 -0700 Subject: * lisp/mouse.el (context-menu-filter-function): Fix type. --- lisp/mouse.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 4c4a7d35a89..54240397001 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -299,7 +299,7 @@ the same menu with changes such as added new menu items." (defcustom context-menu-filter-function nil "Function that can filter the list produced by `context-menu-functions'." - :type 'function + :type '(choice (const nil) function) :version "28.1") (defun context-menu-map () -- cgit v1.2.3 From 1a4ed8ee7843b7cb929f066781a4a754bebf0f4d Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 18 Aug 2021 20:01:03 +0300 Subject: * lisp/mouse.el: More fixes for context-menu. (context-menu-map): Remove menu title "Context Menu" (bug#50067). (context-menu-minor): Reverse sub-menus to display exactly in the same order as on the menu bar. --- etc/NEWS | 5 ++--- lisp/mouse.el | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'lisp/mouse.el') diff --git a/etc/NEWS b/etc/NEWS index cc779b40f45..b221f136241 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -396,9 +396,8 @@ onto 'file-name-history'. *** New minor mode 'context-menu-mode' for context menus popped by 'mouse-3'. When this mode is enabled, clicking 'down-mouse-3' anywhere in the buffer pops up a menu whose contents depends on surrounding context near the -mouse click. You can customize the order of the default sub-menus in -the context menu by customizing the user option -'context-menu-functions'. +mouse click. You can change the order of the default sub-menus in the +context menu by customizing the user option 'context-menu-functions'. +++ *** The "Edit => Clear" menu item now obeys a rectangular region. diff --git a/lisp/mouse.el b/lisp/mouse.el index 54240397001..d2a5200d8de 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -304,7 +304,7 @@ the same menu with changes such as added new menu items." (defun context-menu-map () "Return composite menu map." - (let ((menu (make-sparse-keymap "Context Menu"))) + (let ((menu (make-sparse-keymap))) (run-hook-wrapped 'context-menu-functions (lambda (fun) (setq menu (funcall fun menu)) @@ -341,7 +341,7 @@ the same menu with changes such as added new menu items." "Minor modes submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-minor] menu-bar-separator) - (dolist (mode (minor-mode-key-binding [menu-bar])) + (dolist (mode (reverse (minor-mode-key-binding [menu-bar]))) (when (and (consp mode) (symbol-value (car mode))) (map-keymap (lambda (key binding) (when (consp binding) -- cgit v1.2.3 From e6bea0cbc76bc47f435be9c7f6f3c4b770994924 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 18 Aug 2021 20:32:32 +0300 Subject: Redesign tab-bar event processing (bug#41342, bug#41343) Instead of emitting menu-item keys like [tab-1], emit normal mouse events like [mouse-1] and [down-mouse-3] for all mouse clicks issued on the tab-bar. * lisp/mouse.el (mouse-posn-property): Handle 'tab-bar' posn-area. * lisp/tab-bar.el (tab--key-to-number): New internal function. (tab-bar-handle-mouse): Use tab key to select/close tab. (tab-bar-mouse-select-tab, tab-bar-mouse-close-tab) (tab-bar-mouse-context-menu): New commands. (tab-bar-map): Bind [down-mouse-1] to tab-bar-mouse-select-tab, [down-mouse-2] to tab-bar-mouse-close-tab, [down-mouse-3] to tab-bar-mouse-context-menu. (tab-bar-keymap-cache): Remove. (tab-bar-make-keymap): Don't use cache. (tab-bar--format-tab): Remove default bindings from menu items. (tab-bar-make-keymap-1): Prepend tab-bar-map. * src/keyboard.c (make_lispy_event): Append event->arg to position for Qtab_bar. * src/term.c (handle_one_term_event): Simplify to set event arg. * src/w32inevt.c (do_mouse_event): Set emacs_ev->arg to the value returned from tty_handle_tab_bar_click. * src/w32term.c (w32_handle_tab_bar_click): Return value from handle_tab_bar_click. (w32_read_socket): Set tab_bar_key to value returned from w32_handle_tab_bar_click, and set event arg from it. * src/xdisp.c (handle_tab_bar_click): Instead of emitting event, return a list with Qtab_bar and tab caption with text properties that contain Qmenu_item with key and binding. (tty_handle_tab_bar_click): Simplify to return a list of Qtab_bar, key and close_p, instead of emitting event. * src/xterm.c (handle_one_xevent): Set tab_bar_key to value returned from handle_tab_bar_click, and set event arg from it. --- etc/NEWS | 4 +++ lisp/mouse.el | 7 ++-- lisp/tab-bar.el | 100 +++++++++++++++++++++++++++++++++++-------------------- src/dispextern.h | 4 +-- src/keyboard.c | 6 ++++ src/term.c | 17 ++-------- src/termchar.h | 4 +-- src/w32inevt.c | 6 ++-- src/w32term.c | 20 ++++++----- src/xdisp.c | 81 +++++++++++++++++++------------------------- src/xterm.c | 8 +++-- 11 files changed, 138 insertions(+), 119 deletions(-) (limited to 'lisp/mouse.el') diff --git a/etc/NEWS b/etc/NEWS index 1b4712828c5..cb500dd697e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -748,6 +748,10 @@ of the next command to be displayed in a new frame. ** Tab Bars +*** The tab bar now supports more mouse commands. +Clicking 'mouse-2' closes the tab, 'mouse-3' displays the context menu +with items that operate on the clicked tab. + *** The key prefix 'C-x t t' displays next command buffer in a new tab. It's bound to the command 'other-tab-prefix' that requests the buffer of the next command to be displayed in a new tab. diff --git a/lisp/mouse.el b/lisp/mouse.el index 4c4a7d35a89..0047475a0d5 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -1374,9 +1374,10 @@ its value is returned." ;; Mouse clicks in the fringe come with a position in ;; (nth 5). This is useful but is not exactly where we clicked, so ;; don't look up that position's properties! - (and pt (not (memq (posn-area pos) '(left-fringe right-fringe - left-margin right-margin))) - (get-char-property pt property w)))) + (and pt (not (memq (posn-area pos) + '(left-fringe right-fringe + left-margin right-margin tab-bar))) + (get-char-property pt property w)))) (get-char-property pos property))) (defun mouse-on-link-p (pos) diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 4ec1143128b..91d22b4b7b2 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -27,10 +27,7 @@ ;; bindings for the global tab bar. ;; The normal global binding for [tab-bar] (below) uses the value of -;; `tab-bar-map' as the actual keymap to define the tab bar. Modes -;; may either bind items under the [tab-bar] prefix key of the local -;; map to add to the global bar or may set `tab-bar-map' -;; buffer-locally to override it. +;; `tab-bar-map' as the actual keymap to define the tab bar. ;;; Code: @@ -224,6 +221,11 @@ a list of frames to update." (tab-bar--define-keys) (tab-bar--undefine-keys))) +(defun tab--key-to-number (key) + (unless (or (null key) (eq key 'current-tab)) + (string-to-number + (string-replace "tab-" "" (format "%S" key))))) + (defun tab-bar-handle-mouse (event) "Text-mode emulation of switching tabs on the tab bar. This command is used when you click the mouse in the tab bar @@ -238,18 +240,51 @@ on a console which has no window system but does have a mouse." (lambda (key binding) (when (eq (car-safe binding) 'menu-item) (when (> (+ column (length (nth 1 binding))) x-position) - (if (get-text-property (- x-position column) 'close-tab (nth 1 binding)) - (let* ((close-key (vector (intern (format "C-%s" key)))) - (close-def (lookup-key keymap close-key))) - (when close-def - (call-interactively close-def))) - (call-interactively (nth 2 binding))) + (if (get-text-property + (- x-position column) 'close-tab (nth 1 binding)) + (tab-bar-close-tab (tab--key-to-number key)) + (if (nth 2 binding) + (call-interactively (nth 2 binding)) + (tab-bar-select-tab (tab--key-to-number key)))) (throw 'done t)) (setq column (+ column (length (nth 1 binding)))))) keymap)) ;; Clicking anywhere outside existing tabs will add a new tab (tab-bar-new-tab))))) +(defun tab-bar-mouse-select-tab (event) + (interactive "e") + (if (posn-window (event-start event)) + (let* ((caption (car (posn-string (event-start event)))) + (item (and caption (get-text-property 0 'menu-item caption)))) + (if (nth 2 item) + (tab-bar-close-tab (tab--key-to-number (nth 0 item))) + (if (functionp (nth 1 item)) + (call-interactively (nth 1 item)) + (tab-bar-select-tab (tab--key-to-number (nth 0 item)))))) + ;; TTY + (tab-bar-handle-mouse event))) + +(defun tab-bar-mouse-close-tab (event) + (interactive "e") + (let* ((caption (car (posn-string (event-start event)))) + (item (and caption (get-text-property 0 'menu-item caption)))) + (tab-bar-close-tab (tab--key-to-number (nth 0 item))))) + +(defun tab-bar-mouse-context-menu (event) + (interactive "e") + (let* ((caption (car (posn-string (event-start event)))) + (item (and caption (get-text-property 0 'menu-item caption))) + (tab-number (tab--key-to-number (nth 0 item))) + (menu (make-sparse-keymap "Context Menu"))) + + (define-key-after menu [close] + `(menu-item "Close" (lambda () (interactive) + (tab-bar-close-tab ,tab-number)) + :help "Close the tab")) + + (popup-menu menu event))) + (defun toggle-tab-bar-mode-from-frame (&optional arg) "Toggle tab bar on or off, based on the status of the current frame. Used in the Show/Hide menu, to have the toggle reflect the current frame. @@ -273,24 +308,26 @@ new frame when the global `tab-bar-mode' is enabled, by using (set-frame-parameter frame 'tab-bar-lines-keep-state (not (frame-parameter frame 'tab-bar-lines-keep-state)))) -(defvar tab-bar-map (make-sparse-keymap) - "Keymap for the tab bar. -Define this locally to override the global tab bar.") +(defvar tab-bar-map + (let ((map (make-sparse-keymap))) + (define-key map [down-mouse-1] 'tab-bar-mouse-select-tab) + (define-key map [mouse-1] 'ignore) + (define-key map [down-mouse-2] 'tab-bar-mouse-close-tab) + (define-key map [mouse-2] 'ignore) + (define-key map [down-mouse-3] 'tab-bar-mouse-context-menu) + + map) + "Keymap for the commands used on the tab bar.") (global-set-key [tab-bar] `(menu-item ,(purecopy "tab bar") ignore :filter tab-bar-make-keymap)) -(defconst tab-bar-keymap-cache (make-hash-table :weakness t :test 'equal)) - (defun tab-bar-make-keymap (&optional _ignore) "Generate an actual keymap from `tab-bar-map'. -Its main job is to show tabs in the tab bar." - (if (= 1 (length tab-bar-map)) - (tab-bar-make-keymap-1) - (let ((key (cons (frame-terminal) tab-bar-map))) - (or (gethash key tab-bar-keymap-cache) - (puthash key tab-bar-map tab-bar-keymap-cache))))) +Its main job is to show tabs in the tab bar +and to bind mouse events to the commands." + (tab-bar-make-keymap-1)) (defcustom tab-bar-show t @@ -608,19 +645,12 @@ You can hide these buttons by customizing `tab-bar-format' and removing `((,(intern (format "tab-%i" i)) menu-item ,(funcall tab-bar-tab-name-format-function tab i) - ,(or - (alist-get 'binding tab) - `(lambda () - (interactive) - (tab-bar-select-tab ,i))) + ,(alist-get 'binding tab) :help "Click to visit tab")))) - `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) - menu-item "" - ,(or - (alist-get 'close-binding tab) - `(lambda () - (interactive) - (tab-bar-close-tab ,i))))))) + (when (alist-get 'close-binding tab) + `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) + menu-item "" + ,(alist-get 'close-binding tab)))))) (defun tab-bar-format-tabs () (let ((i 0)) @@ -760,9 +790,7 @@ on the tab bar instead." (defun tab-bar-make-keymap-1 () "Generate an actual keymap from `tab-bar-map', without caching." - (append - '(keymap (mouse-1 . tab-bar-handle-mouse)) - (tab-bar-format-list tab-bar-format))) + (append tab-bar-map (tab-bar-format-list tab-bar-format))) ;; Some window-configuration parameters don't need to be persistent. diff --git a/src/dispextern.h b/src/dispextern.h index 33fcaa4c078..f4c7575b352 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3415,8 +3415,8 @@ extern void get_glyph_string_clip_rect (struct glyph_string *, NativeRectangle *nr); extern Lisp_Object find_hot_spot (Lisp_Object, int, int); -extern void handle_tab_bar_click (struct frame *, - int, int, bool, int); +extern Lisp_Object handle_tab_bar_click (struct frame *, + int, int, bool, int); extern void handle_tool_bar_click (struct frame *, int, int, bool, int); diff --git a/src/keyboard.c b/src/keyboard.c index 2e4c4e6aabf..e25833276c1 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5649,6 +5649,12 @@ make_lispy_event (struct input_event *event) position = make_lispy_position (f, event->x, event->y, event->timestamp); + + if (CONSP (event->arg) && EQ (XCAR (event->arg), Qtab_bar)) + { + XSETCAR (XCDR (position), Qtab_bar); + position = nconc2 (position, Fcons (XCDR (event->arg), Qnil)); + } } #ifndef USE_TOOLKIT_SCROLL_BARS else diff --git a/src/term.c b/src/term.c index c995a4499cf..89b35680034 100644 --- a/src/term.c +++ b/src/term.c @@ -2568,21 +2568,8 @@ handle_one_term_event (struct tty_display_info *tty, Gpm_Event *event) { f->mouse_moved = 0; term_mouse_click (&ie, event, f); - /* eassert (ie.kind == MOUSE_CLICK_EVENT); */ - if (tty_handle_tab_bar_click (f, event->x, event->y, - (ie.modifiers & down_modifier) != 0, &ie)) - { - /* eassert (ie.kind == MOUSE_CLICK_EVENT - * || ie.kind == TAB_BAR_EVENT); */ - /* tty_handle_tab_bar_click stores 2 events in the event - queue, so we are done here. */ - /* FIXME: Actually, `tty_handle_tab_bar_click` returns true - without storing any events, when - (ie.modifiers & down_modifier) != 0 */ - count += 2; - return count; - } - /* eassert (ie.kind == MOUSE_CLICK_EVENT); */ + ie.arg = tty_handle_tab_bar_click (f, event->x, event->y, + (ie.modifiers & down_modifier) != 0, &ie); kbd_buffer_store_event (&ie); count++; } diff --git a/src/termchar.h b/src/termchar.h index f50c1bfb6ea..7ab9337fbe7 100644 --- a/src/termchar.h +++ b/src/termchar.h @@ -234,7 +234,7 @@ extern struct tty_display_info *tty_list; #define CURTTY() FRAME_TTY (SELECTED_FRAME()) struct input_event; -extern bool tty_handle_tab_bar_click (struct frame *, int, int, bool, - struct input_event *); +extern Lisp_Object tty_handle_tab_bar_click (struct frame *, int, int, bool, + struct input_event *); #endif /* EMACS_TERMCHAR_H */ diff --git a/src/w32inevt.c b/src/w32inevt.c index 1255072b7f3..9a69b32bcb0 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c @@ -586,9 +586,8 @@ do_mouse_event (MOUSE_EVENT_RECORD *event, int x = event->dwMousePosition.X; int y = event->dwMousePosition.Y; struct frame *f = get_frame (); - if (tty_handle_tab_bar_click (f, x, y, (button_state & mask) != 0, - emacs_ev)) - return 0; /* tty_handle_tab_bar_click adds the event to queue */ + emacs_ev->arg = tty_handle_tab_bar_click (f, x, y, (button_state & mask) != 0, + emacs_ev); emacs_ev->modifiers |= ((button_state & mask) ? down_modifier : up_modifier); @@ -597,7 +596,6 @@ do_mouse_event (MOUSE_EVENT_RECORD *event, XSETFASTINT (emacs_ev->x, x); XSETFASTINT (emacs_ev->y, y); XSETFRAME (emacs_ev->frame_or_window, f); - emacs_ev->arg = Qnil; return 1; } diff --git a/src/w32term.c b/src/w32term.c index ad4d1a32829..c9570b0c670 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -168,8 +168,8 @@ int w32_keyboard_codepage; int w32_message_fd = -1; #endif /* CYGWIN */ -static void w32_handle_tab_bar_click (struct frame *, - struct input_event *); +static Lisp_Object w32_handle_tab_bar_click (struct frame *, + struct input_event *); static void w32_handle_tool_bar_click (struct frame *, struct input_event *); static void w32_define_cursor (Window, Emacs_Cursor); @@ -3684,17 +3684,17 @@ w32_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, frame-relative coordinates X/Y. EVENT_TYPE is either ButtonPress or ButtonRelease. */ -static void +static Lisp_Object w32_handle_tab_bar_click (struct frame *f, struct input_event *button_event) { int x = XFIXNAT (button_event->x); int y = XFIXNAT (button_event->y); if (button_event->modifiers & down_modifier) - handle_tab_bar_click (f, x, y, 1, 0); + return handle_tab_bar_click (f, x, y, 1, 0); else - handle_tab_bar_click (f, x, y, 0, - button_event->modifiers & ~up_modifier); + return handle_tab_bar_click (f, x, y, 0, + button_event->modifiers & ~up_modifier); } @@ -5186,6 +5186,7 @@ w32_read_socket (struct terminal *terminal, { /* If we decide we want to generate an event to be seen by the rest of Emacs, we put it here. */ + Lisp_Object tab_bar_key = Qnil; bool tab_bar_p = 0; bool tool_bar_p = 0; int button = 0; @@ -5208,12 +5209,12 @@ w32_read_socket (struct terminal *terminal, if (EQ (window, f->tab_bar_window)) { - w32_handle_tab_bar_click (f, &inev); + tab_bar_key = w32_handle_tab_bar_click (f, &inev); tab_bar_p = 1; } } - if (tab_bar_p + if ((tab_bar_p && NILP (tab_bar_key)) || (dpyinfo->w32_focus_frame && f != dpyinfo->w32_focus_frame /* This does not help when the click happens in @@ -5221,6 +5222,9 @@ w32_read_socket (struct terminal *terminal, && !frame_ancestor_p (f, dpyinfo->w32_focus_frame))) inev.kind = NO_EVENT; + if (!NILP (tab_bar_key)) + inev.arg = tab_bar_key; + /* Is this in the tool-bar? */ if (WINDOWP (f->tool_bar_window) && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window))) diff --git a/src/xdisp.c b/src/xdisp.c index 972b90177c6..1a4efba4b82 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13745,7 +13745,7 @@ get_tab_bar_item (struct frame *f, int x, int y, struct glyph **glyph, false for button release. MODIFIERS is event modifiers for button release. */ -void +Lisp_Object handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, int modifiers) { @@ -13763,12 +13763,12 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, /* If the button is released on a tab other than the one where it was pressed, don't generate the tab-bar button click event. */ || (ts != 0 && !down_p)) - return; + return Qnil; /* If item is disabled, do nothing. */ enabled_p = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_ENABLED_P); if (NILP (enabled_p)) - return; + return Qnil; if (down_p) { @@ -13779,24 +13779,24 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, } else { - Lisp_Object key, frame; - struct input_event event; - EVENT_INIT (event); - /* Show item in released state. */ if (!NILP (Vmouse_highlight)) show_mouse_face (hlinfo, DRAW_IMAGE_RAISED); - - key = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_KEY); - - XSETFRAME (frame, f); - event.kind = TAB_BAR_EVENT; - event.frame_or_window = frame; - event.arg = key; - event.modifiers = close_p ? ctrl_modifier | modifiers : modifiers; - kbd_buffer_store_event (&event); f->last_tab_bar_item = -1; } + + Lisp_Object caption = + Fcopy_sequence (AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_CAPTION)); + + AUTO_LIST2 (props, Qmenu_item, + list3 (AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_KEY), + AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_BINDING), + close_p ? Qt : Qnil)); + + Fadd_text_properties (make_fixnum (0), make_fixnum (SCHARS (caption)), + props, caption); + + return Fcons (Qtab_bar, Fcons (caption, make_fixnum (0))); } @@ -13920,14 +13920,14 @@ tty_get_tab_bar_item (struct frame *f, int x, int *idx, ptrdiff_t *end) structure, store it in keyboard queue, and return true; otherwise return false. MODIFIERS are event modifiers for generating the tab release event. */ -bool +Lisp_Object tty_handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, struct input_event *event) { /* Did they click on the tab bar? */ if (y < FRAME_MENU_BAR_LINES (f) || y >= FRAME_MENU_BAR_LINES (f) + FRAME_TAB_BAR_LINES (f)) - return false; + return Qnil; /* Find the tab-bar item where the X,Y coordinates belong. */ int prop_idx; @@ -13935,46 +13935,33 @@ tty_handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, Lisp_Object caption = tty_get_tab_bar_item (f, x, &prop_idx, &clen); if (NILP (caption)) - return false; + return Qnil; if (NILP (AREF (f->tab_bar_items, prop_idx * TAB_BAR_ITEM_NSLOTS + TAB_BAR_ITEM_ENABLED_P))) - return false; + return Qnil; if (down_p) f->last_tab_bar_item = prop_idx; else { - /* Force reset of up_modifier bit from the event modifiers. */ - if (event->modifiers & up_modifier) - event->modifiers &= ~up_modifier; - - /* Generate a TAB_BAR_EVENT event. */ - Lisp_Object frame; - Lisp_Object key = AREF (f->tab_bar_items, - prop_idx * TAB_BAR_ITEM_NSLOTS - + TAB_BAR_ITEM_KEY); - /* Kludge alert: we assume the last two characters of a tab - label are " x", and treat clicks on those 2 characters as a - Close Tab command. */ - eassert (STRINGP (caption)); - int lastc = SSDATA (caption)[SCHARS (caption) - 1]; - bool close_p = false; - if ((x == clen - 1 || (clen > 1 && x == clen - 2)) && lastc == 'x') - close_p = true; - - event->code = 0; - XSETFRAME (frame, f); - event->kind = TAB_BAR_EVENT; - event->frame_or_window = frame; - event->arg = key; - if (close_p) - event->modifiers |= ctrl_modifier; - kbd_buffer_store_event (event); f->last_tab_bar_item = -1; } - return true; + /* Generate a TAB_BAR_EVENT event. */ + Lisp_Object key = AREF (f->tab_bar_items, + prop_idx * TAB_BAR_ITEM_NSLOTS + + TAB_BAR_ITEM_KEY); + /* Kludge alert: we assume the last two characters of a tab + label are " x", and treat clicks on those 2 characters as a + Close Tab command. */ + eassert (STRINGP (caption)); + int lastc = SSDATA (caption)[SCHARS (caption) - 1]; + bool close_p = false; + if ((x == clen - 1 || (clen > 1 && x == clen - 2)) && lastc == 'x') + close_p = true; + + return list3 (Qtab_bar, key, close_p ? Qt : Qnil); } diff --git a/src/xterm.c b/src/xterm.c index 1887c3255d4..80fa747b97d 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -9166,6 +9166,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, { /* If we decide we want to generate an event to be seen by the rest of Emacs, we put it here. */ + Lisp_Object tab_bar_key = Qnil; bool tab_bar_p = false; bool tool_bar_p = false; @@ -9215,7 +9216,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, tab_bar_p = EQ (window, f->tab_bar_window); if (tab_bar_p && event->xbutton.button < 4) - handle_tab_bar_click + tab_bar_key = handle_tab_bar_click (f, x, y, event->xbutton.type == ButtonPress, x_x_to_emacs_modifiers (dpyinfo, event->xbutton.state)); } @@ -9239,7 +9240,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, } #endif /* !USE_GTK */ - if (!tab_bar_p && !tool_bar_p) + if (!(tab_bar_p && NILP (tab_bar_key)) && !tool_bar_p) #if defined (USE_X_TOOLKIT) || defined (USE_GTK) if (! popup_activated ()) #endif @@ -9257,6 +9258,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, } else x_construct_mouse_click (&inev.ie, &event->xbutton, f); + + if (!NILP (tab_bar_key)) + inev.ie.arg = tab_bar_key; } if (FRAME_X_EMBEDDED_P (f)) xembed_send_message (f, event->xbutton.time, -- cgit v1.2.3 From 89c31342a735c631b93ef7d75f3b0672e83f9e95 Mon Sep 17 00:00:00 2001 From: Mattias EngdegĂ„rd Date: Fri, 20 Aug 2021 12:03:20 +0200 Subject: Use C-mouse-1 for context menu on NS The Mac platform convention is to use control-left-click for context menus (as a synonym to right-click). * lisp/mouse.el (context-menu--old-bindings): Remove. (context-menu--saved-bindings) (context-menu--bind-mouse, context-menu--reset-bindings): New. (context-menu-mode): Use new functions, with C-mouse-1 as extra binding on NS. --- lisp/mouse.el | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index d2a5200d8de..4dcc2f28f4a 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -440,8 +440,28 @@ the same menu with changes such as added new menu items." `(menu-item ,(purecopy "Context Menu") ignore :filter (lambda (_) (context-menu-map)))) -(defvar context-menu--old-down-mouse-3 nil) -(defvar context-menu--old-mouse-3 nil) +(defvar context-menu--saved-bindings nil + "Alist of bindings to restore when `context-menu-mode' is disabled.") + +(defun context-menu--bind-mouse (click-sym down-sym) + "Enable `context-menu-mode' mouse bindings. +CLICK-SYM and DOWN-SYM are the mouse click and down key symbols to use." + (let ((click (vector click-sym)) + (down (vector down-sym))) + (push (cons click-sym (global-key-binding click)) + context-menu--saved-bindings) + (global-unset-key click) + (push (cons down-sym (global-key-binding down)) + context-menu--saved-bindings) + (global-set-key down context-menu-entry))) + +(defun context-menu--reset-bindings () + "Restore saved `context-menu-mode' bindings." + (pcase-dolist (`(sym . binding) context-menu--saved-bindings) + (let ((key (vector sym))) + (if binding + (global-set-key key binding) + (global-unset-key key))))) (define-minor-mode context-menu-mode "Toggle Context Menu mode. @@ -449,20 +469,13 @@ the same menu with changes such as added new menu items." When Context Menu mode is enabled, clicking the mouse button down-mouse-3 activates the menu whose contents depends on its surrounding context." :global t :group 'mouse - (cond - (context-menu-mode - (setq context-menu--old-mouse-3 (global-key-binding [mouse-3])) - (global-unset-key [mouse-3]) - (setq context-menu--old-down-mouse-3 (global-key-binding [down-mouse-3])) - (global-set-key [down-mouse-3] context-menu-entry)) - (t - (if (not context-menu--old-down-mouse-3) - (global-unset-key [down-mouse-3]) - (global-set-key [down-mouse-3] context-menu--old-down-mouse-3) - (setq context-menu--old-down-mouse-3 nil)) - (when context-menu--old-mouse-3 - (global-set-key [mouse-3] context-menu--old-mouse-3) - (setq context-menu--old-mouse-3 nil))))) + (if context-menu-mode + (progn + (setq context-menu--saved-bindings nil) + (context-menu--bind-mouse 'mouse-3 'down-mouse-3) + (when (featurep 'ns) + (context-menu--bind-mouse 'C-mouse-1 'C-down-mouse-1))) + (context-menu--restore-bindings))) ;; Commands that operate on windows. -- cgit v1.2.3 From 573e8eef86acb560541226465817d5a84efeebc5 Mon Sep 17 00:00:00 2001 From: Mattias EngdegĂ„rd Date: Fri, 20 Aug 2021 13:51:36 +0200 Subject: ; * lisp/mouse.el: Fix typos in previous change --- lisp/mouse.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 4dcc2f28f4a..3441a4787e6 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -455,9 +455,9 @@ CLICK-SYM and DOWN-SYM are the mouse click and down key symbols to use." context-menu--saved-bindings) (global-set-key down context-menu-entry))) -(defun context-menu--reset-bindings () +(defun context-menu--restore-bindings () "Restore saved `context-menu-mode' bindings." - (pcase-dolist (`(sym . binding) context-menu--saved-bindings) + (pcase-dolist (`(,sym . ,binding) context-menu--saved-bindings) (let ((key (vector sym))) (if binding (global-set-key key binding) -- cgit v1.2.3 From dd7d966eb40b58a221ea29930582b8173ea87ee2 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 22 Aug 2021 11:44:55 +0300 Subject: Don't show menu titles with the text property 'hide' (bug#50067) * lisp/mouse.el (context-menu-map): Add menu title "Context Menu" propertized with the text property 'hide'. * src/menu.c (x_popup_menu_1): Don't show the title with the non-nil text property 'hide' on GTK and NS. --- lisp/mouse.el | 2 +- src/menu.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 3441a4787e6..7cdea34d865 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -304,7 +304,7 @@ the same menu with changes such as added new menu items." (defun context-menu-map () "Return composite menu map." - (let ((menu (make-sparse-keymap))) + (let ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t)))) (run-hook-wrapped 'context-menu-functions (lambda (fun) (setq menu (funcall fun menu)) diff --git a/src/menu.c b/src/menu.c index e441d22ea04..4edd4ce33f9 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1284,6 +1284,14 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu) /* Search for a string appearing directly as an element of the keymap. That string is the title of the menu. */ prompt = Fkeymap_prompt (keymap); + +#if defined (USE_GTK) || defined (HAVE_NS) + if (STRINGP (prompt) + && SCHARS (prompt) > 0 + && !NILP (Fget_text_property (make_fixnum (0), Qhide, prompt))) + title = Qnil; + else +#endif if (!NILP (prompt)) title = prompt; -- cgit v1.2.3 From 6984eea510a579a25bd7811f6d13e1bf2b4a35cb Mon Sep 17 00:00:00 2001 From: Ergus Date: Sun, 22 Aug 2021 11:56:01 +0300 Subject: * lisp/mouse.el (context-menu-mode-map): New variable. (context-menu--saved-bindings, context-menu--bind-mouse) (context-menu--restore-bindings): Remove. (context-menu-mode): Don't use removed functions. --- lisp/mouse.el | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 7cdea34d865..6332d9fcec3 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -440,42 +440,22 @@ the same menu with changes such as added new menu items." `(menu-item ,(purecopy "Context Menu") ignore :filter (lambda (_) (context-menu-map)))) -(defvar context-menu--saved-bindings nil - "Alist of bindings to restore when `context-menu-mode' is disabled.") - -(defun context-menu--bind-mouse (click-sym down-sym) - "Enable `context-menu-mode' mouse bindings. -CLICK-SYM and DOWN-SYM are the mouse click and down key symbols to use." - (let ((click (vector click-sym)) - (down (vector down-sym))) - (push (cons click-sym (global-key-binding click)) - context-menu--saved-bindings) - (global-unset-key click) - (push (cons down-sym (global-key-binding down)) - context-menu--saved-bindings) - (global-set-key down context-menu-entry))) - -(defun context-menu--restore-bindings () - "Restore saved `context-menu-mode' bindings." - (pcase-dolist (`(,sym . ,binding) context-menu--saved-bindings) - (let ((key (vector sym))) - (if binding - (global-set-key key binding) - (global-unset-key key))))) +(defvar context-menu-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [mouse-3] nil) + (define-key map [down-mouse-3] context-menu-entry) + (when (featurep 'ns) + (define-key map [C-mouse-1] nil) + (define-key map [C-down-mouse-1] context-menu-entry)) + map) + "Context Menu mode map.") (define-minor-mode context-menu-mode "Toggle Context Menu mode. When Context Menu mode is enabled, clicking the mouse button down-mouse-3 activates the menu whose contents depends on its surrounding context." - :global t :group 'mouse - (if context-menu-mode - (progn - (setq context-menu--saved-bindings nil) - (context-menu--bind-mouse 'mouse-3 'down-mouse-3) - (when (featurep 'ns) - (context-menu--bind-mouse 'C-mouse-1 'C-down-mouse-1))) - (context-menu--restore-bindings))) + :global t :group 'mouse) ;; Commands that operate on windows. -- cgit v1.2.3 From dcf84bce2500ad2c632ae1d19d6b93324f55e25e Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 23 Aug 2021 10:33:36 +0300 Subject: * lisp/mouse.el (context-menu-toolbar): New function. (context-menu-functions): Add context-menu-toolbar to choice. (context-menu-region): Bind "Paste" to mouse-yank-at-click instead of mouse-yank-primary. https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00735.html --- lisp/mouse.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 6332d9fcec3..28996e373d9 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -289,6 +289,7 @@ the same menu with changes such as added new menu items." :type '(repeat (choice (function-item context-menu-undo) (function-item context-menu-region) + (function-item context-menu-toolbar) (function-item context-menu-global) (function-item context-menu-local) (function-item context-menu-minor) @@ -313,6 +314,17 @@ the same menu with changes such as added new menu items." (setq menu (funcall context-menu-filter-function menu))) menu)) +(defun context-menu-toolbar (menu) + "Tool bar menu items." + (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) + (define-key-after menu [separator-toolbar] menu-bar-separator) + (map-keymap (lambda (key binding) + (when (consp binding) + (define-key-after menu (vector key) + (copy-sequence binding)))) + (lookup-key global-map [tool-bar])) + menu) + (defun context-menu-global (menu) "Global submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) @@ -396,7 +408,7 @@ the same menu with changes such as added new menu items." "\\[ns-copy-including-secondary]" "\\[kill-ring-save]"))) (define-key-after menu [paste] - `(menu-item "Paste" mouse-yank-primary + `(menu-item "Paste" mouse-yank-at-click :visible (funcall ',(lambda () (and (or -- cgit v1.2.3 From 976594d905ceacc3c351735ba099ac71ea31f014 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 23 Aug 2021 20:42:16 +0300 Subject: * lisp/mouse.el (context-menu-open): New command bound to [S-f10]. * doc/emacs/frames.texi (Menu Mouse Clicks): Mention S-F10 to pop up the context menu. * src/callint.c (Fcall_interactively): Use inhibit_mouse_event_check for the case 'e'. (inhibit-mouse-event-check): New variable. https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00733.html --- doc/emacs/frames.texi | 2 ++ etc/NEWS | 7 +++++++ lisp/mouse.el | 9 +++++++++ src/callint.c | 9 ++++++++- 4 files changed, 26 insertions(+), 1 deletion(-) (limited to 'lisp/mouse.el') diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi index d582d24e766..22f22efacac 100644 --- a/doc/emacs/frames.texi +++ b/doc/emacs/frames.texi @@ -370,6 +370,7 @@ This menu is for changing the default face within the window's buffer. @findex context-menu-mode @vindex context-menu-functions @kindex Down-mouse-3 +@kindex S-F10 Many GUI applications use @kbd{mouse-3} to display @dfn{context menus}: menus that provide access to various pertinent settings and actions for the location and context of the mouse click. If you @@ -382,6 +383,7 @@ mode and the buffer contents around the place where you click the mouse. To customize the contents of the context menu, you can use the variable @code{context-menu-functions} (@pxref{Major Mode Conventions,,, elisp, The Emacs Lisp Reference Manual}). +You can also invoke the context menu by pressing @kbd{S-@key{F10}}. @node Mode Line Mouse @section Mode Line Mouse Commands diff --git a/etc/NEWS b/etc/NEWS index b008c46291c..ed77443dbf0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -398,6 +398,7 @@ When this mode is enabled, clicking 'down-mouse-3' anywhere in the buffer pops up a menu whose contents depends on surrounding context near the mouse click. You can change the order of the default sub-menus in the context menu by customizing the user option 'context-menu-functions'. +You can also invoke the context menu by pressing 'S-'. +++ *** The "Edit => Clear" menu item now obeys a rectangular region. @@ -3845,6 +3846,12 @@ to match the behaviour.) When non-nil, matches for identifiers in the file visited by the current buffer will be shown first in the "*xref*" buffer. +--- +** New variable 'inhibit-mouse-event-check'. +If bound to non-nil, a command with '(interactive "e")' +doesn't signal an error when no mouse event is produced +while using the keyboard. + * Changes in Emacs 28.1 on Non-Free Operating Systems diff --git a/lisp/mouse.el b/lisp/mouse.el index 28996e373d9..9d866813848 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -469,6 +469,15 @@ When Context Menu mode is enabled, clicking the mouse button down-mouse-3 activates the menu whose contents depends on its surrounding context." :global t :group 'mouse) +(defun context-menu-open () + "Start key navigation of the context menu. +This is the keyboard interface to \\[context-menu-map]." + (interactive) + (let ((inhibit-mouse-event-check t)) + (popup-menu (context-menu-map) (point)))) + +(global-set-key [S-f10] 'context-menu-open) + ;; Commands that operate on windows. diff --git a/src/callint.c b/src/callint.c index 6f8a7f13f61..5201dc7ba16 100644 --- a/src/callint.c +++ b/src/callint.c @@ -606,7 +606,7 @@ invoke it (via an `interactive' spec that contains, for instance, an break; case 'e': /* The invoking event. */ - if (next_event >= key_count) + if (!inhibit_mouse_event_check && next_event >= key_count) error ("%s must be bound to an event with parameters", (SYMBOLP (function) ? SSDATA (SYMBOL_NAME (function)) @@ -900,6 +900,13 @@ Its purpose is to give temporary modes such as Isearch mode a way to turn themselves off when a mouse command switches windows. */); Vmouse_leave_buffer_hook = Qnil; + DEFVAR_BOOL ("inhibit-mouse-event-check", inhibit_mouse_event_check, + doc: /* Non-nil means the interactive spec "e" doesn't check for events. +In this case `(interactive "e")' doesn't signal an error when no mouse event +is produced while using the keyboard. Then `event-start', `event-end', +`event-click-count' can create a new event. */); + inhibit_mouse_event_check = false; + defsubr (&Sinteractive); defsubr (&Scall_interactively); defsubr (&Sfuncall_interactively); -- cgit v1.2.3 From 9e0d507c37ab44947118cbcab9f21386108fbeb4 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 24 Aug 2021 20:23:02 +0300 Subject: * lisp/mouse.el (context-menu-buffers): New function (bug#50067). (context-menu-functions): Add context-menu-buffers to the choice list. --- lisp/mouse.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 9d866813848..a490aac7445 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -293,6 +293,7 @@ the same menu with changes such as added new menu items." (function-item context-menu-global) (function-item context-menu-local) (function-item context-menu-minor) + (function-item context-menu-buffers) (function-item context-menu-vc) (function-item context-menu-ffap) (function :tag "Custom function"))) @@ -362,6 +363,17 @@ the same menu with changes such as added new menu items." (cdr mode)))) menu) +(defun context-menu-buffers (menu) + "Submenus with buffers." + (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) + (define-key-after menu [separator-buffers] menu-bar-separator) + (map-keymap (lambda (key binding) + (when (consp binding) + (define-key-after menu (vector key) + (copy-sequence binding)))) + (mouse-buffer-menu-keymap)) + menu) + (defun context-menu-vc (menu) "Version Control menu." (define-key-after menu [separator-vc] menu-bar-separator) -- cgit v1.2.3 From b8704b52fde7568516472f1841ad49c717f445d1 Mon Sep 17 00:00:00 2001 From: Ergus Date: Tue, 24 Aug 2021 21:08:54 +0300 Subject: * lisp/mouse.el (context-menu-mode-map): Bind [menu] to context-menu-open. https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg01004.html --- lisp/mouse.el | 1 + 1 file changed, 1 insertion(+) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index a490aac7445..d137419e02a 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -468,6 +468,7 @@ the same menu with changes such as added new menu items." (let ((map (make-sparse-keymap))) (define-key map [mouse-3] nil) (define-key map [down-mouse-3] context-menu-entry) + (define-key map [menu] #'context-menu-open) (when (featurep 'ns) (define-key map [C-mouse-1] nil) (define-key map [C-down-mouse-1] context-menu-entry)) -- cgit v1.2.3 From d54ffa25bd297f9bc57918ca65db714beade7473 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 26 Aug 2021 10:40:35 +0300 Subject: Define a substitute for on MS-Windows * lisp/mouse.el (context-menu-mode-map): On w32, use in addition to (the mostly non-existent) . --- lisp/mouse.el | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index d137419e02a..8b209638423 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -469,6 +469,8 @@ the same menu with changes such as added new menu items." (define-key map [mouse-3] nil) (define-key map [down-mouse-3] context-menu-entry) (define-key map [menu] #'context-menu-open) + (if (featurep 'w32) + (define-key map [apps] #'context-menu-open)) (when (featurep 'ns) (define-key map [C-mouse-1] nil) (define-key map [C-down-mouse-1] context-menu-entry)) -- cgit v1.2.3 From a573d6bd88afe9a60728f0b63a45f44a6ff98ce2 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 27 Aug 2021 09:24:07 +0300 Subject: Replace flyspell-use-mouse-3-for-menu with context-menu-mode (bug#50067) * doc/emacs/fixit.texi (Spelling): Replace mentions of flyspell-use-mouse-3-for-menu with context-menu-mode. * lisp/mouse.el (context-menu-map): Use the function from the text property context-menu-function at mouse click event. * lisp/textmodes/flyspell.el (flyspell--set-use-mouse-3-for-menu): Remove function. (flyspell-use-mouse-3-for-menu): Remove defcustom added recently in 28.1. (flyspell-context-menu): New function. (flyspell-mode): Don't call flyspell--set-use-mouse-3-for-menu. (flyspell-mode-on): Replace flyspell-use-mouse-3-for-menu with context-menu-mode. (make-flyspell-overlay): When context-menu-mode is non-nil, put overlay context-menu-function with flyspell-context-menu instead of using keymap flyspell-mouse-map. --- doc/emacs/fixit.texi | 7 +++---- etc/NEWS | 3 +-- lisp/mouse.el | 13 +++++++++---- lisp/textmodes/flyspell.el | 47 ++++++++++++++++++---------------------------- 4 files changed, 31 insertions(+), 39 deletions(-) (limited to 'lisp/mouse.el') diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi index b558ebc3fdc..85cdbff5fa5 100644 --- a/doc/emacs/fixit.texi +++ b/doc/emacs/fixit.texi @@ -462,10 +462,9 @@ use @code{flyspell-region} or @code{flyspell-buffer} for that. When Flyspell mode highlights a word as misspelled, you can click on it with @kbd{mouse-2} (@code{flyspell-correct-word}) to display a menu of possible corrections and actions. If you want this menu on -@kbd{mouse-3} instead, customize the variable -@code{flyspell-use-mouse-3-for-menu}. In addition, @kbd{C-.} or -@kbd{@key{ESC}-@key{TAB}} (@code{flyspell-auto-correct-word}) will -propose various successive corrections for the word at point, and +@kbd{mouse-3} instead, enable @code{context-menu-mode}. In addition, +@kbd{C-.} or @kbd{@key{ESC}-@key{TAB}} (@code{flyspell-auto-correct-word}) +will propose various successive corrections for the word at point, and @w{@kbd{C-c $}} (@code{flyspell-correct-word-before-point}) will pop up a menu of possible corrections. Of course, you can always correct the misspelled word by editing it manually in any way you like. diff --git a/etc/NEWS b/etc/NEWS index 78aca8cd549..246c89759f8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2875,8 +2875,7 @@ like 'flymake-mode-line-error-counter', When Flyspell mode highlights a word as misspelled, you can click on it to display a menu of possible corrections and actions. You can now easily bind this menu to 'down-mouse-3' (usually the right mouse button) -instead of 'mouse-2' (the default) by customizing the new user option -'flyspell-use-mouse-3-for-menu'. +instead of 'mouse-2' (the default) by enabling 'context-menu-mode'. --- *** The current dictionary is now displayed in the minor mode lighter. diff --git a/lisp/mouse.el b/lisp/mouse.el index 8b209638423..7d3ed9a0e40 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -307,10 +307,15 @@ the same menu with changes such as added new menu items." (defun context-menu-map () "Return composite menu map." (let ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t)))) - (run-hook-wrapped 'context-menu-functions - (lambda (fun) - (setq menu (funcall fun menu)) - nil)) + (let ((fun (mouse-posn-property (event-start last-input-event) + 'context-menu-function))) + (if (functionp fun) + (setq menu (funcall fun menu)) + (run-hook-wrapped 'context-menu-functions + (lambda (fun) + (setq menu (funcall fun menu)) + nil)))) + ;; TODO: remove double separators (when (functionp context-menu-filter-function) (setq menu (funcall context-menu-filter-function menu))) menu)) diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 836d889a1cf..975f540936a 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -442,22 +442,6 @@ like \"Some." map) "Minor mode keymap for Flyspell mode--for the whole buffer.") -;; correct on mouse 3 -(defun flyspell--set-use-mouse-3-for-menu (var value) - (set-default var value) - (if value - (progn (define-key flyspell-mouse-map [mouse-2] nil) - (define-key flyspell-mouse-map [down-mouse-3] 'flyspell-correct-word)) - (define-key flyspell-mouse-map [mouse-2] 'flyspell-correct-word) - (define-key flyspell-mouse-map [down-mouse-3] nil))) - -(defcustom flyspell-use-mouse-3-for-menu nil - "Non-nil means to bind `mouse-3' to `flyspell-correct-word'. -If this is set, also unbind `mouse-2'." - :type 'boolean - :set 'flyspell--set-use-mouse-3-for-menu - :version "28.1") - ;; dash character machinery (defvar-local flyspell-consider-dash-as-word-delimiter-flag nil "Non-nil means that the `-' char is considered as a word delimiter.") @@ -486,6 +470,13 @@ See also `flyspell-duplicate-distance'." (defvar flyspell-overlay nil) +(defun flyspell-context-menu (_menu) + "Context menu for `context-menu-mode'." + ;; TODO: refactor `flyspell-correct-word' and related functions to return + ;; a keymap menu where every menu item is bound to a lambda that calls + ;; `flyspell-do-correct' with an argument that is a correct word. + 'flyspell-correct-word) + ;;*---------------------------------------------------------------------*/ ;;* flyspell-mode ... */ ;;*---------------------------------------------------------------------*/ @@ -537,10 +528,7 @@ in your init file. :group 'flyspell (if flyspell-mode (condition-case err - (progn - (when flyspell-use-mouse-3-for-menu - (flyspell--set-use-mouse-3-for-menu 'flyspell-use-mouse-3-for-menu t)) - (flyspell-mode-on (called-interactively-p 'interactive))) + (flyspell-mode-on (called-interactively-p 'interactive)) (error (message "Error enabling Flyspell mode:\n%s" (cdr err)) (flyspell-mode -1))) (flyspell-mode-off))) @@ -656,8 +644,7 @@ are both non-nil." show-msg) (let* ((binding (where-is-internal 'flyspell-auto-correct-word nil 'non-ascii)) - (mouse-button (if flyspell-use-mouse-3-for-menu - "Mouse-3" "Mouse-2"))) + (mouse-button (if context-menu-mode "Mouse-3" "Mouse-2"))) (message (format-message "Welcome to Flyspell. Use %s to correct words." (if binding @@ -1820,13 +1807,15 @@ for the overlay." (overlay-put overlay 'mouse-face mouse-face) (overlay-put overlay 'flyspell-overlay t) (overlay-put overlay 'evaporate t) - (overlay-put overlay 'help-echo (concat (if flyspell-use-mouse-3-for-menu - "mouse-3" - "mouse-2") ": correct word at point")) - ;; If misspelled text has a 'keymap' property, let that remain in - ;; effect for the bindings that flyspell-mouse-map doesn't override. - (set-keymap-parent flyspell-mouse-map (get-char-property beg 'keymap)) - (overlay-put overlay 'keymap flyspell-mouse-map) + (overlay-put overlay 'help-echo + (concat (if context-menu-mode "mouse-3" "mouse-2") + ": correct word at point")) + (if context-menu-mode + (overlay-put overlay 'context-menu-function 'flyspell-context-menu) + ;; If misspelled text has a 'keymap' property, let that remain in + ;; effect for the bindings that flyspell-mouse-map doesn't override. + (set-keymap-parent flyspell-mouse-map (get-char-property beg 'keymap)) + (overlay-put overlay 'keymap flyspell-mouse-map)) (when (eq face 'flyspell-incorrect) (and (stringp flyspell-before-incorrect-word-string) (overlay-put overlay 'before-string -- cgit v1.2.3 From 1ccc31eff5b6993042cea7df565d6484984701c2 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 12 Sep 2021 19:47:20 +0300 Subject: * lisp/mouse.el (context-menu-map): Remove duplicate separators (bug#50067). * lisp/mouse.el (context-menu-undo, context-menu-region): * lisp/progmodes/prog-mode.el (prog-context-menu): Use 'when' instead of ':visible' that allows to remove duplicate separators created between empty submenus. --- lisp/mouse.el | 120 ++++++++++++++++++++++---------------------- lisp/progmodes/prog-mode.el | 42 ++++++++-------- 2 files changed, 82 insertions(+), 80 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 8c6fb2c71b1..f7ade5f89a5 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -315,7 +315,15 @@ the same menu with changes such as added new menu items." (lambda (fun) (setq menu (funcall fun menu)) nil)))) - ;; TODO: remove double separators + + ;; Remove duplicate separators + (let ((l menu)) + (while l + (when (and (equal (cdr-safe (car l)) menu-bar-separator) + (equal (cdr-safe (cadr l)) menu-bar-separator)) + (setcdr l (cddr l))) + (setq l (cdr l)))) + (when (functionp context-menu-filter-function) (setq menu (funcall context-menu-filter-function menu))) menu)) @@ -387,68 +395,62 @@ the same menu with changes such as added new menu items." (defun context-menu-undo (menu) "Undo menu." - (when (cddr menu) - (define-key-after menu [separator-undo] menu-bar-separator)) - (define-key-after menu [undo] - '(menu-item "Undo" undo - :visible (and (not buffer-read-only) - (not (eq t buffer-undo-list)) - (if (eq last-command 'undo) - (listp pending-undo-list) - (consp buffer-undo-list))) - :help "Undo last edits")) - (define-key-after menu [undo-redo] - '(menu-item "Redo" undo-redo - :visible (and (not buffer-read-only) - (undo--last-change-was-undo-p buffer-undo-list)) - :help "Redo last undone edits")) + (define-key-after menu [separator-undo] menu-bar-separator) + (when (and (not buffer-read-only) + (not (eq t buffer-undo-list)) + (if (eq last-command 'undo) + (listp pending-undo-list) + (consp buffer-undo-list))) + (define-key-after menu [undo] + '(menu-item "Undo" undo + :help "Undo last edits"))) + (when (and (not buffer-read-only) + (undo--last-change-was-undo-p buffer-undo-list)) + (define-key-after menu [undo-redo] + '(menu-item "Redo" undo-redo + :help "Redo last undone edits"))) menu) (defun context-menu-region (menu) "Region commands menu." - (when (cddr menu) - (define-key-after menu [separator-region] menu-bar-separator)) - (define-key-after menu [cut] - '(menu-item "Cut" kill-region - :visible (and mark-active (not buffer-read-only)) - :help - "Cut (kill) text in region between mark and current position")) - (define-key-after menu [copy] - ;; ns-win.el said: Substitute a Copy function that works better - ;; under X (for GNUstep). - `(menu-item "Copy" ,(if (featurep 'ns) - 'ns-copy-including-secondary - 'kill-ring-save) - :visible mark-active - :help "Copy text in region between mark and current position" - :keys ,(if (featurep 'ns) - "\\[ns-copy-including-secondary]" - "\\[kill-ring-save]"))) - (define-key-after menu [paste] - `(menu-item "Paste" mouse-yank-at-click - :visible (funcall - ',(lambda () - (and (or - (gui-backend-selection-exists-p 'CLIPBOARD) - (if (featurep 'ns) ; like paste-from-menu - (cdr yank-menu) - kill-ring)) - (not buffer-read-only)))) - :help "Paste (yank) text most recently cut/copied")) - (define-key-after menu (if (featurep 'ns) [select-paste] - [paste-from-menu]) - ;; ns-win.el said: Change text to be more consistent with - ;; surrounding menu items `paste', etc." - `(menu-item ,(if (featurep 'ns) "Select and Paste" "Paste from Kill Menu") - yank-menu - :visible (and (cdr yank-menu) (not buffer-read-only)) - :help "Choose a string from the kill ring and paste it")) - (define-key-after menu [clear] - '(menu-item "Clear" delete-active-region - :visible (and mark-active - (not buffer-read-only)) - :help - "Delete the text in region between mark and current position")) + (define-key-after menu [separator-region] menu-bar-separator) + (when (and mark-active (not buffer-read-only)) + (define-key-after menu [cut] + '(menu-item "Cut" kill-region + :help + "Cut (kill) text in region between mark and current position"))) + (when mark-active + (define-key-after menu [copy] + ;; ns-win.el said: Substitute a Copy function that works better + ;; under X (for GNUstep). + `(menu-item "Copy" ,(if (featurep 'ns) + 'ns-copy-including-secondary + 'kill-ring-save) + :help "Copy text in region between mark and current position" + :keys ,(if (featurep 'ns) + "\\[ns-copy-including-secondary]" + "\\[kill-ring-save]")))) + (when (and (or (gui-backend-selection-exists-p 'CLIPBOARD) + (if (featurep 'ns) ; like paste-from-menu + (cdr yank-menu) + kill-ring)) + (not buffer-read-only)) + (define-key-after menu [paste] + `(menu-item "Paste" mouse-yank-at-click + :help "Paste (yank) text most recently cut/copied"))) + (when (and (cdr yank-menu) (not buffer-read-only)) + (define-key-after menu (if (featurep 'ns) [select-paste] + [paste-from-menu]) + ;; ns-win.el said: Change text to be more consistent with + ;; surrounding menu items `paste', etc." + `(menu-item ,(if (featurep 'ns) "Select and Paste" "Paste from Kill Menu") + yank-menu + :help "Choose a string from the kill ring and paste it"))) + (when (and mark-active (not buffer-read-only)) + (define-key-after menu [clear] + '(menu-item "Clear" delete-active-region + :help + "Delete the text in region between mark and current position"))) (define-key-after menu [mark-whole-buffer] '(menu-item "Select All" mark-whole-buffer :help "Mark the whole buffer for a subsequent cut/copy")) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index f75a3039d3e..be9b72e47eb 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -47,27 +47,27 @@ (require 'xref) (define-key-after menu [prog-separator] menu-bar-separator 'mark-whole-buffer) - (define-key-after menu [xref-find-def] - '(menu-item "Find Definition" xref-find-definitions-at-mouse - :visible (save-excursion - (mouse-set-point last-input-event) - (xref-backend-identifier-at-point - (xref-find-backend))) - :help "Find definition of identifier") - 'prog-separator) - (define-key-after menu [xref-find-ref] - '(menu-item "Find References" xref-find-references-at-mouse - :visible (save-excursion - (mouse-set-point last-input-event) - (xref-backend-identifier-at-point - (xref-find-backend))) - :help "Find references to identifier") - 'xref-find-def) - (define-key-after menu [xref-pop] - '(menu-item "Back Definition" xref-pop-marker-stack - :visible (not (xref-marker-stack-empty-p)) - :help "Back to the position of the last search") - 'xref-find-ref) + (when (save-excursion + (mouse-set-point last-input-event) + (xref-backend-identifier-at-point + (xref-find-backend))) + (define-key-after menu [xref-find-def] + '(menu-item "Find Definition" xref-find-definitions-at-mouse + :help "Find definition of identifier") + 'prog-separator)) + (when (save-excursion + (mouse-set-point last-input-event) + (xref-backend-identifier-at-point + (xref-find-backend))) + (define-key-after menu [xref-find-ref] + '(menu-item "Find References" xref-find-references-at-mouse + :help "Find references to identifier") + 'xref-find-def)) + (when (not (xref-marker-stack-empty-p)) + (define-key-after menu [xref-pop] + '(menu-item "Back Definition" xref-pop-marker-stack + :help "Back to the position of the last search") + 'xref-find-ref)) menu) (defvar prog-mode-map -- cgit v1.2.3 From 4877ddeaf739af3a683d8686d1e2fa5e51960623 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 12 Sep 2021 20:11:52 +0300 Subject: * lisp/mouse.el (context-menu-map): Add 'click' arg to called funs (bug#50256) (context-menu-toolbar, context-menu-global, context-menu-local) (context-menu-minor, context-menu-buffers, context-menu-vc) (context-menu-undo, context-menu-region, context-menu-ffap): Add 'click' arg. * lisp/dired.el (dired-context-menu): * lisp/help-mode.el (help-mode-context-menu): * lisp/info.el (Info-context-menu): * lisp/net/eww.el (eww-context-menu): * lisp/net/goto-addr.el (goto-address-context-menu): * lisp/progmodes/prog-mode.el (prog-context-menu): Add 'click' arg. --- lisp/dired.el | 4 ++-- lisp/help-mode.el | 4 ++-- lisp/info.el | 4 ++-- lisp/mouse.el | 47 +++++++++++++++++++++++---------------------- lisp/net/eww.el | 6 +++--- lisp/net/goto-addr.el | 4 ++-- lisp/progmodes/prog-mode.el | 6 +++--- 7 files changed, 38 insertions(+), 37 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/dired.el b/lisp/dired.el index 958677cd0c7..1ed83cb95a7 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2193,8 +2193,8 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." ["Delete Image Tag..." image-dired-delete-tag :help "Delete image tag from current or marked files"])) -(defun dired-context-menu (menu) - (when (mouse-posn-property (event-start last-input-event) 'dired-filename) +(defun dired-context-menu (menu click) + (when (mouse-posn-property (event-start click) 'dired-filename) (define-key menu [dired-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Immediate"))) (easy-menu-define nil easy-menu nil diff --git a/lisp/help-mode.el b/lisp/help-mode.el index d224bdcbcf8..d341b4c9e4a 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -70,7 +70,7 @@ ["Customize" help-customize :help "Customize variable or face"])) -(defun help-mode-context-menu (menu) +(defun help-mode-context-menu (menu click) (define-key menu [help-mode-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Help-Mode"))) (easy-menu-define nil easy-menu nil @@ -85,7 +85,7 @@ (when (consp item) (define-key menu (vector (car item)) (cdr item))))) - (when (mouse-posn-property (event-start last-input-event) 'mouse-face) + (when (mouse-posn-property (event-start click) 'mouse-face) (define-key menu [help-mode-push-button] '(menu-item "Follow Link" (lambda (event) (interactive "e") diff --git a/lisp/info.el b/lisp/info.el index c09c75ad484..b861fff744c 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4151,7 +4151,7 @@ If FORK is non-nil, it is passed to `Info-goto-node'." "---" ["Exit" quit-window :help "Stop reading Info"])) -(defun Info-context-menu (menu) +(defun Info-context-menu (menu click) (define-key menu [Info-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Info"))) (easy-menu-define nil easy-menu nil @@ -4164,7 +4164,7 @@ If FORK is non-nil, it is passed to `Info-goto-node'." (when (consp item) (define-key menu (vector (car item)) (cdr item))))) - (when (mouse-posn-property (event-start last-input-event) 'mouse-face) + (when (mouse-posn-property (event-start click) 'mouse-face) (define-key menu [Info-mouse-follow-nearest-node] '(menu-item "Follow Link" Info-mouse-follow-nearest-node :help "Follow a link where you click"))) diff --git a/lisp/mouse.el b/lisp/mouse.el index f7ade5f89a5..bd11ec50d57 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -284,8 +284,8 @@ not it is actually displayed." context-menu-local context-menu-minor) "List of functions that produce the contents of the context menu. -Each function receives the menu as its argument and should return -the same menu with changes such as added new menu items." +Each function receives the menu and the mouse click event as its arguments +and should return the same menu with changes such as added new menu items." :type '(repeat (choice (function-item context-menu-undo) (function-item context-menu-region) @@ -304,17 +304,18 @@ the same menu with changes such as added new menu items." :type '(choice (const nil) function) :version "28.1") -(defun context-menu-map () +(defun context-menu-map (&optional click) "Return composite menu map." - (let ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t)))) - (let ((fun (mouse-posn-property (event-start last-input-event) - 'context-menu-function))) - (if (functionp fun) - (setq menu (funcall fun menu)) - (run-hook-wrapped 'context-menu-functions - (lambda (fun) - (setq menu (funcall fun menu)) - nil)))) + (let* ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t))) + (click (or click last-input-event)) + (fun (mouse-posn-property (event-start click) + 'context-menu-function))) + (if (functionp fun) + (setq menu (funcall fun menu click)) + (run-hook-wrapped 'context-menu-functions + (lambda (fun) + (setq menu (funcall fun menu click)) + nil))) ;; Remove duplicate separators (let ((l menu)) @@ -325,10 +326,10 @@ the same menu with changes such as added new menu items." (setq l (cdr l)))) (when (functionp context-menu-filter-function) - (setq menu (funcall context-menu-filter-function menu))) + (setq menu (funcall context-menu-filter-function menu click))) menu)) -(defun context-menu-toolbar (menu) +(defun context-menu-toolbar (menu _click) "Tool bar menu items." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-toolbar] menu-bar-separator) @@ -339,7 +340,7 @@ the same menu with changes such as added new menu items." (lookup-key global-map [tool-bar])) menu) -(defun context-menu-global (menu) +(defun context-menu-global (menu _click) "Global submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-global] menu-bar-separator) @@ -350,7 +351,7 @@ the same menu with changes such as added new menu items." (lookup-key global-map [menu-bar])) menu) -(defun context-menu-local (menu) +(defun context-menu-local (menu _click) "Major mode submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-local] menu-bar-separator) @@ -363,7 +364,7 @@ the same menu with changes such as added new menu items." keymap))) menu) -(defun context-menu-minor (menu) +(defun context-menu-minor (menu _click) "Minor modes submenus." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-minor] menu-bar-separator) @@ -376,7 +377,7 @@ the same menu with changes such as added new menu items." (cdr mode)))) menu) -(defun context-menu-buffers (menu) +(defun context-menu-buffers (menu _click) "Submenus with buffers." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-buffers] menu-bar-separator) @@ -387,13 +388,13 @@ the same menu with changes such as added new menu items." (mouse-buffer-menu-keymap)) menu) -(defun context-menu-vc (menu) +(defun context-menu-vc (menu _click) "Version Control menu." (define-key-after menu [separator-vc] menu-bar-separator) (define-key-after menu [vc-menu] vc-menu-entry) menu) -(defun context-menu-undo (menu) +(defun context-menu-undo (menu _click) "Undo menu." (define-key-after menu [separator-undo] menu-bar-separator) (when (and (not buffer-read-only) @@ -411,7 +412,7 @@ the same menu with changes such as added new menu items." :help "Redo last undone edits"))) menu) -(defun context-menu-region (menu) +(defun context-menu-region (menu _click) "Region commands menu." (define-key-after menu [separator-region] menu-bar-separator) (when (and mark-active (not buffer-read-only)) @@ -456,10 +457,10 @@ the same menu with changes such as added new menu items." :help "Mark the whole buffer for a subsequent cut/copy")) menu) -(defun context-menu-ffap (menu) +(defun context-menu-ffap (menu click) "File at point menu." (save-excursion - (mouse-set-point last-input-event) + (mouse-set-point click) (when (ffap-guess-file-name-at-point) (define-key menu [ffap-separator] menu-bar-separator) (define-key menu [ffap-at-mouse] diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 90301e92acf..62f19925f62 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1021,7 +1021,7 @@ the like." ["Toggle Paragraph Direction" eww-toggle-paragraph-direction])) map)) -(defun eww-context-menu (menu) +(defun eww-context-menu (menu click) (define-key menu [eww-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Eww"))) (easy-menu-define nil easy-menu nil @@ -1035,8 +1035,8 @@ the like." (when (consp item) (define-key menu (vector (car item)) (cdr item))))) - (when (or (mouse-posn-property (event-start last-input-event) 'shr-url) - (mouse-posn-property (event-start last-input-event) 'image-url)) + (when (or (mouse-posn-property (event-start click) 'shr-url) + (mouse-posn-property (event-start click) 'image-url)) (define-key menu [shr-mouse-browse-url-new-window] `(menu-item "Follow URL in new window" ,(if browse-url-new-window-flag 'shr-mouse-browse-url diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index 2c43d0f7532..97230f42fe8 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -124,8 +124,8 @@ will have no effect.") m) "Keymap to hold goto-addr's mouse key defs under highlighted URLs.") -(defun goto-address-context-menu (menu) - (when (mouse-posn-property (event-start last-input-event) 'goto-address) +(defun goto-address-context-menu (menu click) + (when (mouse-posn-property (event-start click) 'goto-address) (define-key menu [goto-address-separator] menu-bar-separator) (define-key menu [goto-address-at-mouse] '(menu-item "Follow Link" goto-address-at-mouse diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index be9b72e47eb..bd2c6536388 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -43,12 +43,12 @@ display-line-numbers-mode prettify-symbols-mode)) -(defun prog-context-menu (menu) +(defun prog-context-menu (menu click) (require 'xref) (define-key-after menu [prog-separator] menu-bar-separator 'mark-whole-buffer) (when (save-excursion - (mouse-set-point last-input-event) + (mouse-set-point click) (xref-backend-identifier-at-point (xref-find-backend))) (define-key-after menu [xref-find-def] @@ -56,7 +56,7 @@ :help "Find definition of identifier") 'prog-separator)) (when (save-excursion - (mouse-set-point last-input-event) + (mouse-set-point click) (xref-backend-identifier-at-point (xref-find-backend))) (define-key-after menu [xref-find-ref] -- cgit v1.2.3 From aa33e38e21e09045bc2ab598e34f3c1510442cb0 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 12 Sep 2021 20:55:57 +0300 Subject: Allow region-related context menu to be used on selected region with one click * lisp/mouse.el (mouse-drag-track): Don't deactivate the mark for the context menu invoked by down-mouse-3. https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg01577.html --- lisp/mouse.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index bd11ec50d57..c107322815a 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -1583,8 +1583,15 @@ The region will be defined with mark and point." t (lambda () (setq track-mouse old-track-mouse) (setq auto-hscroll-mode auto-hscroll-mode-saved) - (deactivate-mark) - (pop-mark))))) + ;; Don't deactivate the mark when the context menu was invoked + ;; by down-mouse-3 immediately after down-mouse-1 and without + ;; releasing the mouse button with mouse-1. This allows to use + ;; region-related context menu to operate on the selected region. + (unless (and context-menu-mode + (eq (car-safe (aref (this-command-keys-vector) 0)) + 'down-mouse-3)) + (deactivate-mark) + (pop-mark)))))) (defun mouse--drag-set-mark-and-point (start click click-count) (let* ((range (mouse-start-end start click click-count)) -- cgit v1.2.3 From 231a29f36333d10b7122bb9e25da4db8cb03b73d Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 15 Sep 2021 19:00:56 +0300 Subject: Add docstrings to context menu functions, and add middle-separator * lisp/mouse.el (context-menu-functions): Add context-menu-middle-separator to default values. (context-menu-middle-separator): New function. * lisp/replace.el (occur-context-menu): Use middle-separator. * lisp/progmodes/elisp-mode.el (elisp-context-menu): * lisp/progmodes/prog-mode.el (prog-context-menu): Use middle-separator and reorder menu items correspondingly. --- lisp/dired.el | 1 + lisp/help-mode.el | 1 + lisp/info.el | 1 + lisp/mouse.el | 42 +++++++++++++++++++++++++++++------------- lisp/net/dictionary.el | 2 +- lisp/net/eww.el | 1 + lisp/net/goto-addr.el | 1 + lisp/progmodes/elisp-mode.el | 19 ++++++++++--------- lisp/progmodes/prog-mode.el | 27 ++++++++++++++------------- lisp/replace.el | 4 ++-- 10 files changed, 61 insertions(+), 38 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/dired.el b/lisp/dired.el index 1ed83cb95a7..9978d027a98 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2194,6 +2194,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." :help "Delete image tag from current or marked files"])) (defun dired-context-menu (menu click) + "Populate MENU with Dired mode commands at CLICK." (when (mouse-posn-property (event-start click) 'dired-filename) (define-key menu [dired-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Immediate"))) diff --git a/lisp/help-mode.el b/lisp/help-mode.el index d341b4c9e4a..d2066a05f7d 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -71,6 +71,7 @@ :help "Customize variable or face"])) (defun help-mode-context-menu (menu click) + "Populate MENU with Help mode commands at CLICK." (define-key menu [help-mode-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Help-Mode"))) (easy-menu-define nil easy-menu nil diff --git a/lisp/info.el b/lisp/info.el index b861fff744c..8c08eaec3c8 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4152,6 +4152,7 @@ If FORK is non-nil, it is passed to `Info-goto-node'." ["Exit" quit-window :help "Stop reading Info"])) (defun Info-context-menu (menu click) + "Populate MENU with Info commands at CLICK." (define-key menu [Info-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Info"))) (easy-menu-define nil easy-menu nil diff --git a/lisp/mouse.el b/lisp/mouse.el index c107322815a..f33a73f03ff 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -281,6 +281,7 @@ not it is actually displayed." (defcustom context-menu-functions '(context-menu-undo context-menu-region + context-menu-middle-separator context-menu-local context-menu-minor) "List of functions that produce the contents of the context menu. @@ -305,11 +306,19 @@ and should return the same menu with changes such as added new menu items." :version "28.1") (defun context-menu-map (&optional click) - "Return composite menu map." + "Return menu map constructed for context near mouse CLICK. +The menu is populated by calling functions from `context-menu-functions'. +Each function receives the menu and the mouse click event +and returns the same menu after adding own menu items to the composite menu. +When there is a text property `context-menu-function' at CLICK, +it overrides all functions from `context-menu-functions'. +At the end, it's possible to modify the final menu by specifying +the function `context-menu-filter-function'." (let* ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t))) (click (or click last-input-event)) (fun (mouse-posn-property (event-start click) 'context-menu-function))) + (if (functionp fun) (setq menu (funcall fun menu click)) (run-hook-wrapped 'context-menu-functions @@ -329,8 +338,14 @@ and should return the same menu with changes such as added new menu items." (setq menu (funcall context-menu-filter-function menu click))) menu)) +(defun context-menu-middle-separator (menu _click) + "Add separator to the middle of the context menu. +Some context functions add menu items below the separator." + (define-key-after menu [middle-separator] menu-bar-separator) + menu) + (defun context-menu-toolbar (menu _click) - "Tool bar menu items." + "Populate MENU with submenus from the tool bar." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-toolbar] menu-bar-separator) (map-keymap (lambda (key binding) @@ -341,7 +356,7 @@ and should return the same menu with changes such as added new menu items." menu) (defun context-menu-global (menu _click) - "Global submenus." + "Populate MENU with submenus from the global menu." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-global] menu-bar-separator) (map-keymap (lambda (key binding) @@ -352,7 +367,7 @@ and should return the same menu with changes such as added new menu items." menu) (defun context-menu-local (menu _click) - "Major mode submenus." + "Populate MENU with submenus provided by major mode." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-local] menu-bar-separator) (let ((keymap (local-key-binding [menu-bar]))) @@ -365,7 +380,7 @@ and should return the same menu with changes such as added new menu items." menu) (defun context-menu-minor (menu _click) - "Minor modes submenus." + "Populate MENU with submenus provided by minor modes." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-minor] menu-bar-separator) (dolist (mode (reverse (minor-mode-key-binding [menu-bar]))) @@ -378,7 +393,7 @@ and should return the same menu with changes such as added new menu items." menu) (defun context-menu-buffers (menu _click) - "Submenus with buffers." + "Populate MENU with the buffer submenus to buffer switching." (run-hooks 'activate-menubar-hook 'menu-bar-update-hook) (define-key-after menu [separator-buffers] menu-bar-separator) (map-keymap (lambda (key binding) @@ -389,13 +404,13 @@ and should return the same menu with changes such as added new menu items." menu) (defun context-menu-vc (menu _click) - "Version Control menu." + "Populate MENU with Version Control commands." (define-key-after menu [separator-vc] menu-bar-separator) (define-key-after menu [vc-menu] vc-menu-entry) menu) (defun context-menu-undo (menu _click) - "Undo menu." + "Populate MENU with undo commands." (define-key-after menu [separator-undo] menu-bar-separator) (when (and (not buffer-read-only) (not (eq t buffer-undo-list)) @@ -413,7 +428,7 @@ and should return the same menu with changes such as added new menu items." menu) (defun context-menu-region (menu _click) - "Region commands menu." + "Populate MENU with region commands." (define-key-after menu [separator-region] menu-bar-separator) (when (and mark-active (not buffer-read-only)) (define-key-after menu [cut] @@ -451,26 +466,27 @@ and should return the same menu with changes such as added new menu items." (define-key-after menu [clear] '(menu-item "Clear" delete-active-region :help - "Delete the text in region between mark and current position"))) + "Delete text in region between mark and current position"))) (define-key-after menu [mark-whole-buffer] '(menu-item "Select All" mark-whole-buffer :help "Mark the whole buffer for a subsequent cut/copy")) menu) (defun context-menu-ffap (menu click) - "File at point menu." + "Populate MENU with commands that find file at point." (save-excursion (mouse-set-point click) (when (ffap-guess-file-name-at-point) (define-key menu [ffap-separator] menu-bar-separator) (define-key menu [ffap-at-mouse] '(menu-item "Find File or URL" ffap-at-mouse - :help "Find file or URL guessed from text around mouse click")))) + :help "Find file or URL from text around mouse click")))) menu) (defvar context-menu-entry `(menu-item ,(purecopy "Context Menu") ignore - :filter (lambda (_) (context-menu-map)))) + :filter (lambda (_) (context-menu-map))) + "Menu item that creates the context menu and can be bound to a mouse key.") (defvar context-menu-mode-map (let ((map (make-sparse-keymap))) diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el index 9353b4d3759..4947caba699 100644 --- a/lisp/net/dictionary.el +++ b/lisp/net/dictionary.el @@ -1376,7 +1376,7 @@ any buffer where (dictionary-tooltip-mode 1) has been called." (dictionary-search word))) (defun context-menu-dictionary (menu click) - "Dictionary context menu." + "Populate MENU with dictionary commands at CLICK." (when (thing-at-mouse click 'word) (define-key menu [dictionary-separator] menu-bar-separator) (define-key menu [dictionary-search-word-at-mouse] diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 16a13bbaaee..28569eeeb10 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1027,6 +1027,7 @@ the like." map)) (defun eww-context-menu (menu click) + "Populate MENU with eww commands at CLICK." (define-key menu [eww-separator] menu-bar-separator) (let ((easy-menu (make-sparse-keymap "Eww"))) (easy-menu-define nil easy-menu nil diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index 97230f42fe8..78f6f3d915b 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -125,6 +125,7 @@ will have no effect.") "Keymap to hold goto-addr's mouse key defs under highlighted URLs.") (defun goto-address-context-menu (menu click) + "Populate MENU with goto-address commands at CLICK." (when (mouse-posn-property (event-start click) 'goto-address) (define-key menu [goto-address-separator] menu-bar-separator) (define-key menu [goto-address-at-mouse] diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index f71718bed52..55325ef488b 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -154,23 +154,24 @@ All commands in `lisp-mode-shared-map' are inherited by this map.") :selected (bound-and-true-p eldoc-mode)])) (defun elisp-context-menu (menu click) + "Populate MENU with symbol help commands at CLICK." (when (thing-at-mouse click 'symbol) (define-key-after menu [elisp-separator] menu-bar-separator - 'mark-whole-buffer) + 'middle-separator) + (define-key-after menu [info-lookup-symbol] + '(menu-item "Look up Symbol" + (lambda (click) (interactive "e") + (info-lookup-symbol + (intern (thing-at-mouse click 'symbol t)))) + :help "Display definition in relevant manual") + 'elisp-separator) (define-key-after menu [describe-symbol] '(menu-item "Describe Symbol" (lambda (click) (interactive "e") (describe-symbol (intern (thing-at-mouse click 'symbol t)))) :help "Display the full documentation of symbol") - 'elisp-separator) - (define-key-after menu [info-lookup-symbol] - '(menu-item "Lookup Symbol" - (lambda (click) (interactive "e") - (info-lookup-symbol - (intern (thing-at-mouse click 'symbol t)))) - :help "Display definition in relevant manual") - 'describe-symbol)) + 'elisp-separator)) menu) (defun emacs-lisp-byte-compile () diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index bd2c6536388..88d55a647c8 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -44,30 +44,31 @@ prettify-symbols-mode)) (defun prog-context-menu (menu click) + "Populate MENU with xref commands at CLICK." (require 'xref) (define-key-after menu [prog-separator] menu-bar-separator - 'mark-whole-buffer) + 'middle-separator) + (when (not (xref-marker-stack-empty-p)) + (define-key-after menu [xref-pop] + '(menu-item "Back Definition" xref-pop-marker-stack + :help "Back to the position of the last search") + 'prog-separator)) (when (save-excursion (mouse-set-point click) (xref-backend-identifier-at-point (xref-find-backend))) - (define-key-after menu [xref-find-def] - '(menu-item "Find Definition" xref-find-definitions-at-mouse - :help "Find definition of identifier") + (define-key-after menu [xref-find-ref] + '(menu-item "Find References" xref-find-references-at-mouse + :help "Find references to identifier") 'prog-separator)) (when (save-excursion (mouse-set-point click) (xref-backend-identifier-at-point (xref-find-backend))) - (define-key-after menu [xref-find-ref] - '(menu-item "Find References" xref-find-references-at-mouse - :help "Find references to identifier") - 'xref-find-def)) - (when (not (xref-marker-stack-empty-p)) - (define-key-after menu [xref-pop] - '(menu-item "Back Definition" xref-pop-marker-stack - :help "Back to the position of the last search") - 'xref-find-ref)) + (define-key-after menu [xref-find-def] + '(menu-item "Find Definition" xref-find-definitions-at-mouse + :help "Find definition of identifier") + 'prog-separator)) menu) (defvar prog-mode-map diff --git a/lisp/replace.el b/lisp/replace.el index 63b58c9b454..947da8a2feb 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -2380,13 +2380,13 @@ See also `multi-occur'." (occur (concat "\\_<" (regexp-quote symbol) "\\_>")))) (defun occur-context-menu (menu click) - "Populate MENU with occur commands for CLICK. + "Populate MENU with occur commands at CLICK. To be added to `context-menu-functions'." (let ((word (thing-at-mouse click 'word)) (sym (thing-at-mouse click 'symbol))) (when (or word sym) (define-key-after menu [occur-separator] menu-bar-separator - 'mark-whole-buffer) + 'middle-separator) (when sym (define-key-after menu [occur-symbol-at-mouse] '(menu-item "Occur Symbol" occur-symbol-at-mouse) -- cgit v1.2.3 From ac6afe9c3386c126b819ff8447b04329ec4b4204 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 22 Sep 2021 20:08:45 +0300 Subject: Many improvements for Context Menus (bug#9054) * lisp/menu-bar.el (menu-bar-showhide-menu): Add "Context Menus". * lisp/mouse.el (context-menu-undo): Add "in Region" to the titles when the region is active. (context-menu-region): Use 'mouse-yank-from-menu' in menu items created from 'yank-menu' for submenu "Paste from Kill Menu". (context-menu-region): Add submenu "Select" with things to mark. (mark-thing-at-mouse, mouse-yank-from-menu): New functions. * lisp/thingatpt.el (bounds-of-thing-at-mouse): New function. * lisp/progmodes/elisp-mode.el (elisp-context-menu): * lisp/progmodes/prog-mode.el (prog-context-menu): Use full symbol/identifier names in :help strings. Suggested by Martin Rudalics --- lisp/menu-bar.el | 5 +++ lisp/mouse.el | 77 ++++++++++++++++++++++++++++++++++++-------- lisp/progmodes/elisp-mode.el | 19 +++++------ lisp/progmodes/prog-mode.el | 33 +++++++++---------- lisp/thingatpt.el | 27 ++++++++++------ 5 files changed, 111 insertions(+), 50 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index d863f34df1c..07f7beb92c8 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -1315,6 +1315,11 @@ mail status in mode line")) :visible (and (display-graphic-p) (fboundp 'x-show-tip)) :button (:toggle . tooltip-mode))) + (bindings--define-key menu [showhide-context-menu] + '(menu-item "Context Menus" context-menu-mode + :help "Turn mouse-3 context menus on/off" + :button (:toggle . context-menu-mode))) + (bindings--define-key menu [menu-bar-mode] '(menu-item "Menu Bar" toggle-menu-bar-mode-from-frame :help "Turn menu bar on/off" diff --git a/lisp/mouse.el b/lisp/mouse.el index f33a73f03ff..edac5085ff8 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -418,16 +418,16 @@ Some context functions add menu items below the separator." (listp pending-undo-list) (consp buffer-undo-list))) (define-key-after menu [undo] - '(menu-item "Undo" undo + `(menu-item ,(if (region-active-p) "Undo in Region" "Undo") undo :help "Undo last edits"))) (when (and (not buffer-read-only) (undo--last-change-was-undo-p buffer-undo-list)) (define-key-after menu [undo-redo] - '(menu-item "Redo" undo-redo + `(menu-item (if undo-in-region "Redo in Region" "Redo") undo-redo :help "Redo last undone edits"))) menu) -(defun context-menu-region (menu _click) +(defun context-menu-region (menu click) "Populate MENU with region commands." (define-key-after menu [separator-region] menu-bar-separator) (when (and mark-active (not buffer-read-only)) @@ -455,21 +455,52 @@ Some context functions add menu items below the separator." `(menu-item "Paste" mouse-yank-at-click :help "Paste (yank) text most recently cut/copied"))) (when (and (cdr yank-menu) (not buffer-read-only)) - (define-key-after menu (if (featurep 'ns) [select-paste] - [paste-from-menu]) - ;; ns-win.el said: Change text to be more consistent with - ;; surrounding menu items `paste', etc." - `(menu-item ,(if (featurep 'ns) "Select and Paste" "Paste from Kill Menu") - yank-menu - :help "Choose a string from the kill ring and paste it"))) + (let ((submenu (make-sparse-keymap (propertize "Paste from Kill Menu")))) + (dolist (item yank-menu) + (when (consp item) + (define-key-after submenu (vector (car item)) + `(menu-item ,(cadr item) + ,(lambda () (interactive) + (mouse-yank-from-menu click (car item))))))) + (define-key-after menu (if (featurep 'ns) [select-paste] [paste-from-menu]) + `(menu-item ,(if (featurep 'ns) "Select and Paste" "Paste from Kill Menu") + ,submenu + :help "Choose a string from the kill ring and paste it")))) (when (and mark-active (not buffer-read-only)) (define-key-after menu [clear] '(menu-item "Clear" delete-active-region :help "Delete text in region between mark and current position"))) - (define-key-after menu [mark-whole-buffer] - '(menu-item "Select All" mark-whole-buffer - :help "Mark the whole buffer for a subsequent cut/copy")) + + (let ((submenu (make-sparse-keymap (propertize "Select")))) + (define-key-after submenu [mark-whole-buffer] + `(menu-item "All" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'buffer)) + :help "Mark the whole buffer for a subsequent cut/copy")) + (define-key-after submenu [mark-line] + `(menu-item "Line" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line)) + :help "Mark the line at click for a subsequent cut/copy")) + (define-key-after submenu [mark-defun] + `(menu-item "Defun" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'defun)) + :help "Mark the defun at click for a subsequent cut/copy")) + (define-key-after submenu [mark-list] + `(menu-item "List" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list)) + :help "Mark the list at click for a subsequent cut/copy")) + (define-key-after submenu [mark-symbol] + `(menu-item "Symbol" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'symbol)) + :help "Mark the symbol at click for a subsequent cut/copy")) + (when (region-active-p) + (define-key-after submenu [mark-none] + `(menu-item "None" + ,(lambda (_e) (interactive "e") (deactivate-mark)) + :help "Deactivate the region"))) + + (define-key-after menu [select-region] + `(menu-item "Select" ,submenu))) menu) (defun context-menu-ffap (menu click) @@ -517,6 +548,26 @@ This is the keyboard interface to \\[context-menu-map]." (global-set-key [S-f10] 'context-menu-open) +(defun mark-thing-at-mouse (click thing) + "Activate the region around THING found near the mouse CLICK." + (let ((bounds (bounds-of-thing-at-mouse click thing))) + (when bounds + (goto-char (if mouse-select-region-move-to-beginning + (car bounds) (cdr bounds))) + (push-mark (if mouse-select-region-move-to-beginning + (cdr bounds) (car bounds)) + t 'activate)))) + +(defun mouse-yank-from-menu (click string) + "Insert STRING at mouse CLICK." + ;; Give temporary modes such as isearch a chance to turn off. + (run-hooks 'mouse-leave-buffer-hook) + (when select-active-regions + (deactivate-mark)) + (or mouse-yank-at-point (mouse-set-point click)) + (push-mark) + (insert string)) + ;; Commands that operate on windows. diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index ce45de7f6cf..0b2395d9761 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -158,22 +158,13 @@ All commands in `lisp-mode-shared-map' are inherited by this map.") (when (thing-at-mouse click 'symbol) (define-key-after menu [elisp-separator] menu-bar-separator 'middle-separator) - (define-key-after menu [info-lookup-symbol] - '(menu-item "Look up in Manual" - (lambda (click) (interactive "e") - (info-lookup-symbol - (intern (thing-at-mouse click 'symbol t)))) - :help "Display definition in relevant manual") - 'elisp-separator) + (let* ((string (thing-at-mouse click 'symbol t)) (symbol (when (stringp string) (intern string))) (title (cond ((not (symbolp symbol)) nil) ((and (facep symbol) (not (fboundp symbol))) "Face") - ((and (fboundp symbol) (boundp symbol) - (memq symbol minor-mode-list)) - "Mode") ((and (fboundp symbol) (not (or (boundp symbol) (facep symbol)))) "Function") @@ -183,11 +174,17 @@ All commands in `lisp-mode-shared-map' are inherited by this map.") ((or (fboundp symbol) (boundp symbol) (facep symbol)) "Symbol")))) (when title + (define-key-after menu [info-lookup-symbol] + `(menu-item "Look up in Manual" + (lambda (_click) (interactive "e") + (info-lookup-symbol ',symbol)) + :help ,(format "Find `%s' in relevant manual" symbol)) + 'elisp-separator) (define-key-after menu [describe-symbol] `(menu-item (format "Describe %s" ,title) (lambda (_click) (interactive "e") (describe-symbol ',symbol)) - :help "Display the full documentation of symbol") + :help ,(format "Display the documentation of `%s'" symbol)) 'elisp-separator)))) menu) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 88d55a647c8..7f70e02b72e 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -48,27 +48,26 @@ (require 'xref) (define-key-after menu [prog-separator] menu-bar-separator 'middle-separator) - (when (not (xref-marker-stack-empty-p)) + + (unless (xref-marker-stack-empty-p) (define-key-after menu [xref-pop] '(menu-item "Back Definition" xref-pop-marker-stack :help "Back to the position of the last search") 'prog-separator)) - (when (save-excursion - (mouse-set-point click) - (xref-backend-identifier-at-point - (xref-find-backend))) - (define-key-after menu [xref-find-ref] - '(menu-item "Find References" xref-find-references-at-mouse - :help "Find references to identifier") - 'prog-separator)) - (when (save-excursion - (mouse-set-point click) - (xref-backend-identifier-at-point - (xref-find-backend))) - (define-key-after menu [xref-find-def] - '(menu-item "Find Definition" xref-find-definitions-at-mouse - :help "Find definition of identifier") - 'prog-separator)) + + (let ((identifier (save-excursion + (mouse-set-point click) + (xref-backend-identifier-at-point + (xref-find-backend))))) + (when identifier + (define-key-after menu [xref-find-ref] + `(menu-item "Find References" xref-find-references-at-mouse + :help ,(format "Find references to `%s'" identifier)) + 'prog-separator) + (define-key-after menu [xref-find-def] + `(menu-item "Find Definition" xref-find-definitions-at-mouse + :help ,(format "Find definition of `%s'" identifier)) + 'prog-separator))) menu) (defvar prog-mode-map diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 0af6d56ccc7..6670857df18 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -151,15 +151,6 @@ positions of the thing found." (if (and (<= real-beg orig) (<= orig end) (< real-beg end)) (cons real-beg end)))))))))) -;;;###autoload -(defun thing-at-mouse (event thing &optional no-properties) - "Return the THING at mouse click. -Like `thing-at-point', but tries to use the event -where the mouse button is clicked to find a thing nearby." - (save-excursion - (mouse-set-point event) - (thing-at-point thing no-properties))) - ;;;###autoload (defun thing-at-point (thing &optional no-properties) "Return the THING at point. @@ -196,6 +187,24 @@ a symbol as a valid THING." (set-text-properties 0 (length text) nil text)) text))) +;;;###autoload +(defun bounds-of-thing-at-mouse (event thing) + "Determine the start and end locations for the THING at mouse click. +Like `bounds-of-thing-at-point', but tries to use the EVENT +where the mouse button is clicked to find the thing nearby." + (save-excursion + (mouse-set-point event) + (bounds-of-thing-at-point thing))) + +;;;###autoload +(defun thing-at-mouse (event thing &optional no-properties) + "Return the THING at mouse click. +Like `thing-at-point', but tries to use the EVENT +where the mouse button is clicked to find the thing nearby." + (save-excursion + (mouse-set-point event) + (thing-at-point thing no-properties))) + ;; Go to beginning/end (defun beginning-of-thing (thing) -- cgit v1.2.3 From aebba085cba13ad1439462923ffa0520456f1aad Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Wed, 22 Sep 2021 20:26:40 +0200 Subject: ; More minor stylistic fixes found by checkdoc --- lisp/allout.el | 35 +++++++++--------- lisp/ansi-color.el | 2 +- lisp/apropos.el | 4 +-- lisp/auth-source.el | 8 ++--- lisp/autoinsert.el | 7 ++-- lisp/bindings.el | 6 ++-- lisp/bookmark.el | 17 +++++---- lisp/buff-menu.el | 6 ++-- lisp/button.el | 45 +++++++++++------------ lisp/calc/calc-aent.el | 3 +- lisp/calc/calc-forms.el | 15 ++++---- lisp/calc/calc-poly.el | 2 +- lisp/calc/calc.el | 12 +++---- lisp/calculator.el | 9 +++-- lisp/calendar/diary-lib.el | 7 ++-- lisp/char-fold.el | 2 ++ lisp/cmuscheme.el | 2 +- lisp/comint.el | 2 +- lisp/cus-edit.el | 4 +-- lisp/cus-theme.el | 2 ++ lisp/dabbrev.el | 3 +- lisp/dired-aux.el | 4 +-- lisp/dired-x.el | 4 +-- lisp/dired.el | 5 ++- lisp/display-fill-column-indicator.el | 2 +- lisp/dos-vars.el | 6 ++-- lisp/edmacro.el | 13 +++---- lisp/elec-pair.el | 2 +- lisp/epa-dired.el | 2 ++ lisp/epa-file.el | 3 +- lisp/epa-hook.el | 2 ++ lisp/epa-mail.el | 3 +- lisp/epa.el | 11 +++--- lisp/epg.el | 4 ++- lisp/face-remap.el | 2 +- lisp/faces.el | 4 +-- lisp/ffap.el | 10 +++--- lisp/fileloop.el | 1 + lisp/files.el | 4 +-- lisp/filesets.el | 14 ++++---- lisp/find-dired.el | 2 +- lisp/foldout.el | 2 +- lisp/font-core.el | 2 ++ lisp/forms.el | 4 +-- lisp/hexl.el | 2 +- lisp/hi-lock.el | 2 +- lisp/image-dired.el | 4 +-- lisp/imenu.el | 3 +- lisp/indent.el | 15 ++++---- lisp/info-look.el | 6 ++-- lisp/international/ccl.el | 13 +++---- lisp/international/quail.el | 3 +- lisp/international/robin.el | 3 +- lisp/isearch.el | 2 +- lisp/jit-lock.el | 2 +- lisp/kmacro.el | 4 +-- lisp/loadhist.el | 3 +- lisp/locate.el | 2 +- lisp/macros.el | 13 ++++--- lisp/menu-bar.el | 6 ++-- lisp/mouse-drag.el | 2 +- lisp/mouse.el | 2 +- lisp/nxml/nxml-mode.el | 3 +- lisp/nxml/rng-loc.el | 4 +-- lisp/nxml/rng-valid.el | 5 ++- lisp/pcmpl-x.el | 2 ++ lisp/play/5x5.el | 6 ++-- lisp/play/doctor.el | 4 +-- lisp/play/dunnet.el | 12 +++---- lisp/play/hanoi.el | 2 +- lisp/play/mpuz.el | 2 +- lisp/play/tetris.el | 2 +- lisp/printing.el | 12 +++---- lisp/profiler.el | 6 ++-- lisp/progmodes/cc-bytecomp.el | 30 ++++++++-------- lisp/progmodes/cc-cmds.el | 5 +-- lisp/progmodes/cc-defs.el | 14 ++++---- lisp/progmodes/cc-engine.el | 10 +++--- lisp/progmodes/cc-fonts.el | 2 +- lisp/progmodes/cc-langs.el | 3 +- lisp/progmodes/cc-mode.el | 2 +- lisp/progmodes/cc-vars.el | 2 +- lisp/progmodes/cmacexp.el | 2 +- lisp/progmodes/compile.el | 8 +++-- lisp/progmodes/cperl-mode.el | 4 +-- lisp/progmodes/cpp.el | 6 ++-- lisp/progmodes/dcl-mode.el | 4 +-- lisp/progmodes/ebnf-yac.el | 2 +- lisp/progmodes/f90.el | 6 ++-- lisp/progmodes/flymake.el | 4 +-- lisp/progmodes/gdb-mi.el | 6 ++-- lisp/progmodes/grep.el | 4 +-- lisp/progmodes/hideshow.el | 2 +- lisp/progmodes/idlwave.el | 2 +- lisp/progmodes/opascal.el | 5 +-- lisp/progmodes/prog-mode.el | 4 +-- lisp/progmodes/project.el | 4 +-- lisp/progmodes/verilog-mode.el | 4 +-- lisp/progmodes/vhdl-mode.el | 67 +++++++++++++++++------------------ lisp/progmodes/xref.el | 2 +- lisp/rect.el | 4 +-- lisp/repeat.el | 2 +- lisp/replace.el | 13 +++---- lisp/ruler-mode.el | 2 +- lisp/server.el | 2 +- lisp/ses.el | 10 +++--- lisp/shell.el | 3 +- lisp/simple.el | 18 ++++++---- lisp/so-long.el | 8 ++--- lisp/sort.el | 3 +- lisp/subr.el | 2 ++ lisp/tempo.el | 2 +- lisp/term.el | 38 ++++++++++---------- lisp/textmodes/bib-mode.el | 2 +- lisp/textmodes/flyspell.el | 2 +- lisp/textmodes/makeinfo.el | 7 ++-- lisp/textmodes/mhtml-mode.el | 2 ++ lisp/textmodes/refill.el | 2 +- lisp/textmodes/reftex-dcr.el | 19 +++++----- lisp/textmodes/reftex-global.el | 6 ++-- lisp/textmodes/reftex-index.el | 4 +-- lisp/textmodes/reftex-parse.el | 6 ++-- lisp/textmodes/reftex-vars.el | 9 ++--- lisp/textmodes/texinfmt.el | 14 ++++---- lisp/transient.el | 4 +-- lisp/wdired.el | 4 +-- lisp/whitespace.el | 6 ++-- lisp/wid-edit.el | 7 ++-- lisp/woman.el | 4 +-- 129 files changed, 447 insertions(+), 408 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/allout.el b/lisp/allout.el index bb365246587..c123e8ded4c 100644 --- a/lisp/allout.el +++ b/lisp/allout.el @@ -116,7 +116,7 @@ Do NOT set the value of this variable. Instead, customize "Create the allout keymap according to the keybinding specs, and set it. Useful standalone or to effect customizations of the -respective allout-mode keybinding variables, `allout-command-prefix', +respective `allout-mode' keybinding variables, `allout-command-prefix', `allout-prefixed-keybindings', and `allout-unprefixed-keybindings'" ;; Set the customization variable, if any: (when varname @@ -145,7 +145,7 @@ respective allout-mode keybinding variables, `allout-command-prefix', (allout-institute-keymap map))) ;;;_ > allout-institute-keymap (map) (defun allout-institute-keymap (map) - "Associate allout-mode bindings with allout as a minor mode." + "Associate `allout-mode' bindings with allout as a minor mode." ;; Architecture: ;; allout-mode-map var is a keymap by virtue of being a defalias for ;; allout-mode-map-value, which has the actual keymap value. @@ -358,7 +358,7 @@ Examples: See `allout-expose-topic' for more about the exposure process. Also, allout's mode-specific provisions will make topic prefixes default -to the comment-start string, if any, of the language of the file. This +to the `comment-start' string, if any, of the language of the file. This is modulo the setting of `allout-use-mode-specific-leader', which see." :type 'allout-layout-type :group 'allout) @@ -429,8 +429,7 @@ those that do not have the variable `comment-start' set. A value of ;;;_ = allout-show-bodies (defcustom allout-show-bodies nil - "If non-nil, show entire body when exposing a topic, rather than -just the header." + "If non-nil, show entire body when exposing a topic, rather than just the header." :type 'boolean :group 'allout) (make-variable-buffer-local 'allout-show-bodies) @@ -596,16 +595,16 @@ strings." "When non-nil, use mode-specific topic-header prefixes. Allout outline mode will use the mode-specific `allout-mode-leaders' or -comment-start string, if any, to lead the topic prefix string, so topic +`comment-start' string, if any, to lead the topic prefix string, so topic headers look like comments in the programming language. It will also use -the comment-start string, with an `_' appended, for `allout-primary-bullet'. +the `comment-start' string, with an `_' appended, for `allout-primary-bullet'. String values are used as literals, not regular expressions, so do not escape any regular-expression characters. Value t means to first check for assoc value in `allout-mode-leaders' -alist, then use comment-start string, if any, then use default (`.'). -\(See note about use of comment-start strings, below.) +alist, then use `comment-start' string, if any, then use default (`.'). +\(See note about use of `comment-start' strings, below.) Set to the symbol for either of `allout-mode-leaders' or `comment-start' to use only one of them, respectively. @@ -613,9 +612,9 @@ Set to the symbol for either of `allout-mode-leaders' or Value nil means to always use the default (`.') and leave `allout-primary-bullet' unaltered. -comment-start strings that do not end in spaces are tripled in +`comment-start' strings that do not end in spaces are tripled in the header-prefix, and an `_' underscore is tacked on the end, to -distinguish them from regular comment strings. comment-start +distinguish them from regular comment strings. `comment-start' strings that do end in spaces are not tripled, but an underscore is substituted for the space. [This presumes that the space is for appearance, not comment syntax. You can use @@ -633,8 +632,8 @@ undesired.]" (defvar allout-mode-leaders '() "Specific allout-prefix leading strings per major modes. -Use this if the mode's comment-start string isn't what you -prefer, or if the mode lacks a comment-start string. See +Use this if the mode's `comment-start' string isn't what you +prefer, or if the mode lacks a `comment-start' string. See `allout-use-mode-specific-leader' for more details. If you're constructing a string that will comment-out outline @@ -860,7 +859,7 @@ For details, see `allout-toggle-current-subtree-encryption's docstring." ;;;_ : Version ;;;_ = allout-version (defvar allout-version "2.3" - "Version of currently loaded outline package. (allout.el)") + "Version of currently loaded allout.el package.") ;;;_ > allout-version (defun allout-version (&optional here) "Return string describing the loaded outline version." @@ -1509,7 +1508,7 @@ See `allout-encryption-ciphertext-rejection-regexps' for rejection reasons.") 'allout-mode) ;;;_ > allout-write-contents-hook-handler () (defun allout-write-contents-hook-handler () - "Implement `allout-encrypt-unencrypted-on-saves' for file writes + "Implement `allout-encrypt-unencrypted-on-saves' for file writes. Return nil if all goes smoothly, or else return an informative message if an error is encountered. The message will serve as a @@ -3998,8 +3997,7 @@ With repeat count, shift topic depth by that amount." index do-successors sans-offspring) - "Like `allout-rebullet-topic', but on nearest containing topic -\(visible or not). + "Like `allout-rebullet-topic', but on nearest containing topic (visible or not). See `allout-rebullet-heading' for rebulleting behavior. @@ -5056,8 +5054,7 @@ Examples: max-pos))) ;;;_ > allout-old-expose-topic (spec &rest followers) (defun allout-old-expose-topic (spec &rest followers) - "Deprecated. Use `allout-expose-topic' (with different schema -format) instead. + "Deprecated. Use `allout-expose-topic' (with different schema format) instead. Dictate wholesale exposure scheme for current topic, according to SPEC. diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el index 79b1c9912f5..4315a7f3cef 100644 --- a/lisp/ansi-color.el +++ b/lisp/ansi-color.el @@ -604,7 +604,7 @@ codes. Finally, the so changed list of codes is returned." codes)) (defun ansi-color-make-color-map () - "Creates a vector of face definitions and returns it. + "Create a vector of face definitions and return it. The index into the vector is an ANSI code. See the documentation of `ansi-color-map' for an example. diff --git a/lisp/apropos.el b/lisp/apropos.el index 513175d7513..fc15cd3e011 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -1305,7 +1305,7 @@ as a heading." (error "There is nothing to follow here")))) (defun apropos-next-symbol () - "Move cursor down to the next symbol in an apropos-mode buffer." + "Move cursor down to the next symbol in an `apropos-mode' buffer." (interactive) (forward-line) (while (and (not (eq (face-at-point) 'apropos-symbol)) @@ -1313,7 +1313,7 @@ as a heading." (forward-line))) (defun apropos-previous-symbol () - "Move cursor back to the last symbol in an apropos-mode buffer." + "Move cursor back to the last symbol in an `apropos-mode' buffer." (interactive) (forward-line -1) (while (and (not (eq (face-at-point) 'apropos-symbol)) diff --git a/lisp/auth-source.el b/lisp/auth-source.el index d938522c803..3c1a6feaeeb 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el @@ -176,7 +176,7 @@ Overrides `password-cache-expiry' through a let-binding." ;; TODO: or maybe leave as (setq auth-source-netrc-use-gpg-tokens 'never) (defcustom auth-source-netrc-use-gpg-tokens 'never - "Set this to tell auth-source when to create GPG password + "Set this to tell `auth-source' when to create GPG password tokens in netrc files. It's either an alist or `never'. Note that if EPA/EPG is not available, this should NOT be used." :version "23.2" ;; No Gnus @@ -503,7 +503,7 @@ soon as a function returns non-nil.") (add-hook 'auth-source-backend-parser-functions #'auth-source-backends-parser-secrets) (defun auth-source-backend-parse-parameters (entry backend) - "Fill in the extra auth-source-backend parameters of ENTRY. + "Fill in the extra `auth-source-backend' parameters of ENTRY. Using the plist ENTRY, get the :host, :port, and :user search parameters." (let ((entry (if (stringp entry) @@ -1227,7 +1227,7 @@ FILE is the file from which we obtained this token." &key backend require create type max host user port &allow-other-keys) - "Given a property list SPEC, return search matches from the :backend. + "Given a property list SPEC, return search matches from the `:backend'. See `auth-source-search' for details on SPEC." ;; just in case, check that the type is correct (null or same as the backend) (cl-assert (or (null type) (eq type (oref backend type))) @@ -2274,7 +2274,7 @@ entries for git.gnus.org: &key backend require type max host user port &allow-other-keys) - "Given a property list SPEC, return search matches from the :backend. + "Given a property list SPEC, return search matches from the `:backend'. See `auth-source-search' for details on SPEC." ;; just in case, check that the type is correct (null or same as the backend) (cl-assert (or (null type) (eq type (oref backend type))) diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el index 995d9e2e0fe..063d0a14d63 100644 --- a/lisp/autoinsert.el +++ b/lisp/autoinsert.el @@ -83,10 +83,11 @@ When this is `function', only ask when called non-interactively." (const :tag "Ask if called non-interactively" function) (other :tag "Ask" t))) -(defcustom auto-insert-prompt "Perform %s auto-insertion? " - "Prompt to use when querying whether to auto-insert. +(defcustom auto-insert-prompt "Perform %s auto-insertion?" + "Prompt to use when querying whether to `auto-insert'. If this contains a %s, that will be replaced by the matching rule." - :type 'string) + :type 'string + :version "28.1") (defcustom auto-insert-alist diff --git a/lisp/bindings.el b/lisp/bindings.el index 5c1adef9b50..343f1ba0fa7 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -184,8 +184,8 @@ mouse-3: Remove current window from display")) (defvar mode-line-front-space '(:eval (if (display-graphic-p) " " "-")) "Mode line construct to put at the front of the mode line. By default, this construct is displayed right at the beginning of -the mode line, except that if there is a memory-full message, it -is displayed first.") +the mode line, except that if there is a \"memory full\" message, +it is displayed first.") (put 'mode-line-front-space 'risky-local-variable t) (defun mode-line-mule-info-help-echo (window _object _point) @@ -1086,7 +1086,7 @@ if `inhibit-field-text-motion' is non-nil." (define-key map "p" 'previous-error) (define-key map "\M-p" 'previous-error) map) - "Keymap to repeat next-error key sequences. Used in `repeat-mode'.") + "Keymap to repeat `next-error' key sequences. Used in `repeat-mode'.") (put 'next-error 'repeat-map 'next-error-repeat-map) (put 'previous-error 'repeat-map 'next-error-repeat-map) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index ac63c8f1b0a..d64966df5af 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -905,7 +905,9 @@ others are still there, should the user decide to delete the most recent one. To yank words from the text of the buffer and use them as part of the -bookmark name, type C-w while setting a bookmark. Successive C-w's +bookmark name, type \\\ +\\[bookmark-yank-word] while setting a bookmark. Successive \ +\\[bookmark-yank-word]'s yank successive words. Typing \\[universal-argument] inserts (at the bookmark name prompt) the name of the last @@ -938,7 +940,9 @@ Otherwise, if a bookmark named NAME already exists but PUSH-BOOKMARK is nil, raise an error. To yank words from the text of the buffer and use them as part of the -bookmark name, type C-w while setting a bookmark. Successive C-w's +bookmark name, type \\\ +\\[bookmark-yank-word] while setting a bookmark. Successive \ +\\[bookmark-yank-word]'s yank successive words. Typing \\[universal-argument] inserts (at the bookmark name prompt) the name of the last @@ -1361,7 +1365,8 @@ If called from Lisp, prompt for NEW-NAME if only OLD-NAME was passed as an argument. If called with two strings, then no prompting is done. You must pass at least OLD-NAME when calling from Lisp. -While you are entering the new name, consecutive C-w's insert +While you are entering the new name, consecutive \ +\\\\[bookmark-yank-word]'s insert consecutive words from the text of the buffer into the new bookmark name." (interactive (list (bookmark-completing-read "Old bookmark name"))) @@ -1734,8 +1739,8 @@ unique numeric suffixes \"<2>\", \"<3>\", etc." (define-key map [mouse-2] 'bookmark-bmenu-other-window-with-mouse) map)) -(easy-menu-define - bookmark-menu bookmark-bmenu-mode-map "Bookmark Menu" +(easy-menu-define bookmark-menu bookmark-bmenu-mode-map + "Menu for `bookmark-bmenu'." '("Bookmark" ["Select Bookmark in This Window" bookmark-bmenu-this-window t] ["Select Bookmark in Full-Frame Window" bookmark-bmenu-1-window t] @@ -2062,7 +2067,7 @@ You can mark bookmarks with the \\\\[bookmark-bmenu-mar (defun bookmark-bmenu-save () "Save the current list into a bookmark file. -With a prefix arg, prompts for a file to save them in. +With a prefix arg, prompt for a file to save them in. See also the related behaviors of `bookmark-load' and `bookmark-bmenu-load'." diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index 340c926f8d6..1013a7c4973 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -222,7 +222,7 @@ In Buffer Menu mode, the following commands are defined: so the Buffer Menu remains visible in its window. \\[Buffer-menu-view] Select current line's buffer, in View mode. \\[Buffer-menu-view-other-window] Select that buffer in - another window, in view-mode. + another window, in `view-mode'. \\[Buffer-menu-switch-other-window] Make another window display that buffer. \\[Buffer-menu-mark] Mark current line's buffer to be displayed. \\[Buffer-menu-select] Select current line's buffer. @@ -233,7 +233,7 @@ In Buffer Menu mode, the following commands are defined: \\[Buffer-menu-isearch-buffers] Incremental search in the marked buffers. \\[Buffer-menu-isearch-buffers-regexp] Isearch for regexp in the marked buffers. \\[Buffer-menu-multi-occur] Show lines matching regexp in the marked buffers. -\\[Buffer-menu-visit-tags-table] visit-tags-table this buffer. +\\[Buffer-menu-visit-tags-table] `visit-tags-table' this buffer. \\[Buffer-menu-not-modified] Clear modified-flag on that buffer. \\[Buffer-menu-save] Mark that buffer to be saved, and move down. \\[Buffer-menu-delete] Mark that buffer to be deleted, and move down. @@ -306,7 +306,7 @@ ARG, show only buffers that are visiting files." (display-buffer (list-buffers-noselect arg))) (defun Buffer-menu-toggle-files-only (arg) - "Toggle whether the current buffer-menu displays only file buffers. + "Toggle whether the current `buffer-menu' displays only file buffers. With a positive ARG, display only file buffers. With zero or negative ARG, display other buffers as well." (interactive "P" Buffer-menu-mode) diff --git a/lisp/button.el b/lisp/button.el index 74dfb5d5419..aedd07b762d 100644 --- a/lisp/button.el +++ b/lisp/button.el @@ -113,21 +113,22 @@ Mode-specific keymaps may want to use this as their parent keymap.") ;; [this is an internal function] (defsubst button-category-symbol (type) - "Return the symbol used by button-type TYPE to store properties. + "Return the symbol used by `button-type' TYPE to store properties. Buttons inherit them by setting their `category' property to that symbol." (or (get type 'button-category-symbol) (error "Unknown button type `%s'" type))) (defun define-button-type (name &rest properties) "Define a `button type' called NAME (a symbol). -The remaining arguments form a plist of PROPERTY VALUE pairs, -specifying properties to use as defaults for buttons with this type -\(a button's type may be set by giving it a `type' property when -creating the button, using the :type keyword argument). +The remaining PROPERTIES arguments form a plist of PROPERTY VALUE +pairs, specifying properties to use as defaults for buttons with +this type (a button's type may be set by giving it a `type' +property when creating the button, using the :type keyword +argument). In addition, the keyword argument :supertype may be used to specify a -button-type from which NAME inherits its default property values -\(however, the inheritance happens only when NAME is defined; subsequent +`button-type' from which NAME inherits its default property values +(however, the inheritance happens only when NAME is defined; subsequent changes to a supertype are not reflected in its subtypes)." (let ((catsym (make-symbol (concat (symbol-name name) "-button"))) (super-catsym @@ -156,15 +157,15 @@ changes to a supertype are not reflected in its subtypes)." name)) (defun button-type-put (type prop val) - "Set the button-type TYPE's PROP property to VAL." + "Set the `button-type' TYPE's PROP property to VAL." (put (button-category-symbol type) prop val)) (defun button-type-get (type prop) - "Get the property of button-type TYPE named PROP." + "Get the property of `button-type' TYPE named PROP." (get (button-category-symbol type) prop)) (defun button-type-subtype-p (type supertype) - "Return non-nil if button-type TYPE is a subtype of SUPERTYPE." + "Return non-nil if `button-type' TYPE is a subtype of SUPERTYPE." (or (eq type supertype) (and type (button-type-subtype-p (button-type-get type 'supertype) @@ -271,11 +272,11 @@ This function only works when BUTTON is in the current buffer." (button-end button)))) (defsubst button-type (button) - "Return BUTTON's button-type." + "Return BUTTON's `button-type'." (button-get button 'type)) (defun button-has-type-p (button type) - "Return non-nil if BUTTON has button-type TYPE, or one of its subtypes." + "Return non-nil if BUTTON has `button-type' TYPE, or one of its subtypes." (button-type-subtype-p (button-get button 'type) type)) (defun button--area-button-p (b) @@ -290,10 +291,10 @@ Such area buttons are used for buttons in the mode-line and header-line." (defun make-button (beg end &rest properties) "Make a button from BEG to END in the current buffer. -The remaining arguments form a plist of PROPERTY VALUE pairs, -specifying properties to add to the button. +The remaining PROPERTIES arguments form a plist of PROPERTY VALUE +pairs, specifying properties to add to the button. In addition, the keyword argument :type may be used to specify a -button-type from which to inherit other properties; see +`button-type' from which to inherit other properties; see `define-button-type'. Also see `make-text-button', `insert-button'." @@ -314,7 +315,7 @@ Also see `make-text-button', `insert-button'." The remaining arguments form a plist of PROPERTY VALUE pairs, specifying properties to add to the button. In addition, the keyword argument :type may be used to specify a -button-type from which to inherit other properties; see +`button-type' from which to inherit other properties; see `define-button-type'. Also see `insert-text-button', `make-button'." @@ -328,10 +329,10 @@ Also see `insert-text-button', `make-button'." (defun make-text-button (beg end &rest properties) "Make a button from BEG to END in the current buffer. -The remaining arguments form a plist of PROPERTY VALUE pairs, -specifying properties to add to the button. +The remaining PROPERTIES arguments form a plist of PROPERTY VALUE +pairs, specifying properties to add to the button. In addition, the keyword argument :type may be used to specify a -button-type from which to inherit other properties; see +`button-type' from which to inherit other properties; see `define-button-type'. This function is like `make-button', except that the button is actually @@ -382,10 +383,10 @@ Also see `insert-text-button'." (defun insert-text-button (label &rest properties) "Insert a button with the label LABEL. -The remaining arguments form a plist of PROPERTY VALUE pairs, -specifying properties to add to the button. +The remaining PROPERTIES arguments form a plist of PROPERTY VALUE +pairs, specifying properties to add to the button. In addition, the keyword argument :type may be used to specify a -button-type from which to inherit other properties; see +`button-type' from which to inherit other properties; see `define-button-type'. This function is like `insert-button', except that the button is diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el index 0e913ddfdb9..52c024865a7 100644 --- a/lisp/calc/calc-aent.el +++ b/lisp/calc/calc-aent.el @@ -537,8 +537,7 @@ The value t means abort and give an error message.") ("₋" "-") ; - ("₍" "(") ; ( ("₎" ")")) ; ) - "A list whose elements (old new) indicate replacements to make -in Calc algebraic input.") + "A list indicating replacements to make in Calc algebraic input.") (defvar math-read-superscripts "⁰ÂčÂČ³⁎⁔⁶⁷⁞âčâșâ»âœâŸâżâ±" ; 0123456789+-()ni diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el index ac57011da04..ce8e3579f48 100644 --- a/lisp/calc/calc-forms.el +++ b/lisp/calc/calc-forms.el @@ -703,16 +703,19 @@ in the Gregorian calendar." fmt)))) (defconst math-julian-date-beginning '(float 17214245 -1) - "The beginning of the Julian date calendar, -as measured in the number of days before December 31, 1 BC (Gregorian).") + "The beginning of the Julian date calendar. +This is measured in the number of days before December 31, 1 +BC (Gregorian).") (defconst math-julian-date-beginning-int 1721425 - "The beginning of the Julian date calendar, -as measured in the integer number of days before December 31, 1 BC (Gregorian).") + "The beginning of the Julian date calendar. +This is measured in the integer number of days before December +31, 1 BC (Gregorian).") (defconst math-unix-epoch 719163 - "The beginning of Unix time: days from December 31, 1 BC (Gregorian) -to Jan 1, 1970 AD.") + "The beginning of Unix time. +This is measured in the integer number of days from December 31, +1 BC (Gregorian) to Jan 1, 1970 AD.") (defun math-format-date-part (x) (cond ((stringp x) diff --git a/lisp/calc/calc-poly.el b/lisp/calc/calc-poly.el index 77587cc4b86..5d74a8f106b 100644 --- a/lisp/calc/calc-poly.el +++ b/lisp/calc/calc-poly.el @@ -454,7 +454,7 @@ This returns only the remainder from the pseudo-division." (defun math-atomic-factorp (expr) - "Return true if is a factor containing no sums or quotients." + "Return non-nil if is a factor containing no sums or quotients." (cond ((eq (car-safe expr) '*) (and (math-atomic-factorp (nth 1 expr)) (math-atomic-factorp (nth 2 expr)))) diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index afb43c0f338..45a4d56a371 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -400,8 +400,7 @@ This is not required to be present for user-written mode annotations." :type 'boolean) (defcustom calc-ensure-consistent-units nil - "If non-nil, make sure new units are consistent with current units -when converting units." + "If non-nil, ensure new units are consistent with current units when converting." :version "24.3" :type 'boolean) @@ -468,11 +467,11 @@ This is 1 unless `calc-truncate-stack' has been used.") (defvar calc-display-sci-high 0 "Floating-point numbers with this positive exponent or higher above the -current precision are displayed in scientific notation in calc-mode.") +current precision are displayed in scientific notation in `calc-mode'.") (defvar calc-display-sci-low -3 "Floating-point numbers with this negative exponent or lower are displayed -scientific notation in calc-mode.") +scientific notation in `calc-mode'.") (defvar calc-digit-after-point nil "If t, display at least one digit after the decimal point, as in `12.0'. @@ -493,8 +492,7 @@ This setting only applies to floats in normal display mode.") "List of variables used in customizing GNU Calc.") (defmacro defcalcmodevar (var defval &optional doc) - "Declare VAR as a Calc variable, with default value DEFVAL -and doc-string DOC. + "Declare VAR as a Calc variable, with default value DEFVAL and doc-string DOC. The variable VAR will be added to `calc-mode-var-list'." `(progn (defvar ,var ,defval ,doc) @@ -912,7 +910,7 @@ Used by `calc-user-invocation'.") (defvar calc-trail-pointer nil "The \"current\" entry in trail buffer.") (defvar calc-trail-overlay nil - "The value of overlay-arrow-string.") + "The value of `overlay-arrow-string'.") (defvar calc-undo-list nil "The list of previous operations for undo.") (defvar calc-redo-list nil diff --git a/lisp/calculator.el b/lisp/calculator.el index 415e0b4c77c..6bcea2d885e 100644 --- a/lisp/calculator.el +++ b/lisp/calculator.el @@ -833,8 +833,7 @@ The result should not exceed the screen width." (concat prompt (if (<= trim 0) expr (substring expr trim))))) (defun calculator-string-to-number (str) - "Convert the given STR to a number, according to the value of -`calculator-input-radix'." + "Convert STR to number according to `calculator-input-radix'." (if calculator-input-radix (string-to-number str (cadr (assq calculator-input-radix '((bin 2) (oct 8) (hex 16))))) @@ -1171,9 +1170,9 @@ arguments." ;;; Input interaction (defun calculator-last-input (&optional keys) - "Return the last key sequence that was used to invoke this command, or -the input KEYS. Uses the `function-key-map' translate keypad numbers to -plain ones." + "Return the last key sequence used to invoke this command, or the input KEYS. +Uses the `function-key-map' translate keypad numbers to plain +ones." (let* ((inp (or keys (this-command-keys))) (inp (or (and (arrayp inp) (not (stringp inp)) (lookup-key function-key-map inp)) diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 9ca7ce3f003..2eb7977a164 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -1223,8 +1223,7 @@ ensure that all relevant variables are set. \(diary-mail-entries) -# diary-rem.el ends here -" +# diary-rem.el ends here" (interactive "P") (if (string-equal diary-mail-addr "") (user-error "You must set `diary-mail-addr' to use this command") @@ -1254,10 +1253,10 @@ the regexp with parentheses." paren)) (defvar diary-marking-entries-flag nil - "True during the marking of diary entries, nil otherwise.") + "Non-nil during the marking of diary entries, nil otherwise.") (defvar diary-marking-entry-flag nil - "True during the marking of diary entries, if current entry is marking.") + "Non-nil during the marking of diary entries, if current entry is marking.") ;; file-glob-attrs bound in diary-mark-entries. (defun diary-mark-entries-1 (markfunc &optional months symbol absfunc) diff --git a/lisp/char-fold.el b/lisp/char-fold.el index 46a3f93d0af..e3ab7d5b64c 100644 --- a/lisp/char-fold.el +++ b/lisp/char-fold.el @@ -20,6 +20,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: (eval-and-compile diff --git a/lisp/cmuscheme.el b/lisp/cmuscheme.el index 0910ea6187e..e197069d6b8 100644 --- a/lisp/cmuscheme.el +++ b/lisp/cmuscheme.el @@ -186,7 +186,7 @@ Return before the end of the process' output copies the sexp ending at point Delete converts tabs to spaces as it moves back. Tab indents for Scheme; with argument, shifts rest of expression rigidly with the current line. -C-M-q does Tab on each line starting within following expression. +\\[indent-pp-sexp] does Tab on each line starting within following expression. Paragraphs are separated only by blank lines. Semicolons start comments. If you accidentally suspend your process, use \\[comint-continue-subjob] to continue it." diff --git a/lisp/comint.el b/lisp/comint.el index 56d4420e609..8bf23897f9e 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -2830,7 +2830,7 @@ if necessary." (when (>= count 0) (comint-update-fence)))) (defun comint-kill-region (beg end) - "Like `kill-region', but ignores read-only properties, if safe. + "Like `kill-region', but ignore read-only properties, if safe. This command assumes that the buffer contains read-only \"prompts\" which are regions with front-sticky read-only properties at the beginning of a line, with the preceding newline diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 7eae2e416bb..69baf17f5ee 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -5123,8 +5123,8 @@ If several parents are listed, go to the first of them." The following commands are available: \\\ -Move to next button, link or editable field. \\[widget-forward] -Move to previous button, link or editable field. \\[widget-backward] +Move to next button, link or editable field. \\[widget-forward] +Move to previous button, link or editable field. \\[widget-backward] \\\ Complete content of editable text field. \\[widget-complete] \\\ diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el index 7457d9e3236..07881e9b74e 100644 --- a/lisp/cus-theme.el +++ b/lisp/cus-theme.el @@ -22,6 +22,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: (require 'widget) diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index e113cc94c33..037787797bb 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el @@ -568,8 +568,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." major-mode))) (defun dabbrev--goto-start-of-abbrev () - "Back over all abbrev type characters and then moves forward over -all skip characters." + "Back over all abbrev type characters then move forward over all skip characters." ;; Move backwards over abbrev chars (save-match-data (when (> (point) (minibuffer-prompt-end)) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 4549f45ef67..1bb5b929353 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -1326,7 +1326,7 @@ Return nil if no change in files." (user-error "No compression rule found for \ `dired-compress-directory-default-suffix' %s, see `dired-compress-files-alist' for\ - the supported suffixes list." + the supported suffixes list" dired-compress-directory-default-suffix))) (let* ((suffix (or dired-compress-file-default-suffix ".gz")) (out-name (concat file suffix)) @@ -1335,7 +1335,7 @@ Return nil if no change in files." dired-compress-file-alist))) (if (not rule) (user-error "No compression rule found for suffix %s, \ -see `dired-compress-file-alist' for the supported suffixes list." +see `dired-compress-file-alist' for the supported suffixes list" dired-compress-file-default-suffix) (and (file-exists-p file) (or (not (file-exists-p out-name)) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 9f9f1701730..cf257c8169d 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -589,7 +589,7 @@ This is useful if you want to peruse and move around in an ls -lR output file, for example one you got from an ftp server. With ange-ftp, you can even Dired a directory containing an ls-lR file, visit that file and turn on Virtual Dired mode. But don't try to save -this file, as dired-virtual indents the listing and thus changes the +this file, as `dired-virtual' indents the listing and thus changes the buffer. If you have saved a Dired buffer in a file you can use \\[dired-virtual] to @@ -956,7 +956,7 @@ as the variable `file'. If several COMMANDs are given, the first one will be the default and the rest will be added temporarily to the history and can be retrieved -with \\[previous-history-element] (M-p) . +with `previous-history-element' (\\\\[previous-history-element]). The variable `dired-guess-shell-case-fold-search' controls whether REGEXP is matched case-sensitively." diff --git a/lisp/dired.el b/lisp/dired.el index 266a03e6cc3..07c13e18b95 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2219,8 +2219,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." ;; Autoload cookie needed by desktop.el ;;;###autoload (defun dired-mode (&optional dirname switches) - "\ -Mode for \"editing\" directory listings. + "Mode for \"editing\" directory listings. In Dired, you are \"editing\" a list of the files in a directory and (optionally) its subdirectories, in the format of `ls -lR'. Each directory is a page: use \\[backward-page] and \\[forward-page] to move pagewise. @@ -3697,7 +3696,7 @@ no ARGth marked file is found before this line." (defun dired-mark-files-in-region (start end) (let ((inhibit-read-only t)) (if (> start end) - (error "start > end")) + (error "Start > End")) (goto-char start) ; assumed at beginning of line (while (< (point) end) ;; Skip subdir line and following garbage like the `total' line: diff --git a/lisp/display-fill-column-indicator.el b/lisp/display-fill-column-indicator.el index 50252af4533..7e9d62c5d1a 100644 --- a/lisp/display-fill-column-indicator.el +++ b/lisp/display-fill-column-indicator.el @@ -45,7 +45,7 @@ ;;;###autoload (define-minor-mode display-fill-column-indicator-mode - "Toggle display of fill-column indicator. + "Toggle display of `fill-column' indicator. This uses `display-fill-column-indicator' internally. To change the position of the column displayed by default diff --git a/lisp/dos-vars.el b/lisp/dos-vars.el index 2f7b3760e3f..7fcbb56d224 100644 --- a/lisp/dos-vars.el +++ b/lisp/dos-vars.el @@ -34,9 +34,9 @@ :type '(repeat string)) (defcustom dos-codepage-setup-hook nil - "List of functions to be called after the DOS terminal and coding -systems are set up. This is the place, e.g., to set specific entries -in `standard-display-table' as appropriate for your codepage, if + "List of functions to call after setting up DOS terminal and coding systems. +This is the place, e.g., to set specific entries in +`standard-display-table' as appropriate for your codepage, if `IT-display-table-setup' doesn't do a perfect job." :type '(hook) :version "20.3.3") diff --git a/lisp/edmacro.el b/lisp/edmacro.el index 8ee413acd06..e90b3a006ef 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -108,7 +108,7 @@ With a prefix argument, format the macro in a more concise way." (memq cmd-noremap '(call-last-kbd-macro kmacro-call-macro kmacro-end-or-call-macro kmacro-end-and-call-macro)) (member keys '("\r" [return]))) (or last-kbd-macro - (y-or-n-p "No keyboard macro defined. Create one? ") + (y-or-n-p "No keyboard macro defined. Create one?") (keyboard-quit)) (setq mac (or last-kbd-macro "")) (setq keys nil) @@ -244,8 +244,9 @@ or nil, use a compact 80-column format." (and (fboundp cmd) (not (arrayp (symbol-function cmd))) (not (get cmd 'kmacro)) (not (y-or-n-p - (format "Command %s is already defined; %s" - cmd "proceed? "))) + (format + "Command %s is already defined; proceed?" + cmd))) (keyboard-quit)))) t) ((looking-at "Key:\\(.*\\)$") @@ -264,9 +265,9 @@ or nil, use a compact 80-column format." (not (or (arrayp (symbol-function b)) (get b 'kmacro)))) (not (y-or-n-p - (format "Key %s is already defined; %s" - (edmacro-format-keys key 1) - "proceed? "))) + (format + "Key %s is already defined; proceed?" + (edmacro-format-keys key 1)))) (keyboard-quit)))))) t) ((looking-at "Counter:[ \t]*\\([^ \t\n]*\\)[ \t]*$") diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el index 45bc270db6a..ba88c819133 100644 --- a/lisp/elec-pair.el +++ b/lisp/elec-pair.el @@ -63,7 +63,7 @@ When inserting a closing paren character right before the same character, just skip that character instead, so that hitting ( followed by ) results in \"()\" rather than \"())\". -This can be convenient for people who find it easier to hit ) than C-f. +This can be convenient for people who find it easier to hit ) than \\[forward-char]. Can also be a function of one argument (the closer char just inserted), in which case that function's return value is diff --git a/lisp/epa-dired.el b/lisp/epa-dired.el index 8a4f8933bf8..18f3f055745 100644 --- a/lisp/epa-dired.el +++ b/lisp/epa-dired.el @@ -21,6 +21,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: (require 'epa) diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 33bf5adabe6..fe187589aa7 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -21,8 +21,9 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: -;;; Dependencies (require 'epa) (require 'epa-hook) diff --git a/lisp/epa-hook.el b/lisp/epa-hook.el index 99a432c236e..aa196851d4d 100644 --- a/lisp/epa-hook.el +++ b/lisp/epa-hook.el @@ -21,6 +21,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: (defgroup epa-file nil diff --git a/lisp/epa-mail.el b/lisp/epa-mail.el index b9dd437ed12..9b3aa0c7fd3 100644 --- a/lisp/epa-mail.el +++ b/lisp/epa-mail.el @@ -21,8 +21,9 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: -;;; Dependencies (require 'epa) (require 'mail-utils) diff --git a/lisp/epa.el b/lisp/epa.el index ed1dae3e8ae..57d355cb3e0 100644 --- a/lisp/epa.el +++ b/lisp/epa.el @@ -20,8 +20,9 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: -;;; Dependencies (require 'epg) (eval-when-compile (require 'subr-x)) @@ -461,7 +462,7 @@ q trust status questionable. - trust status unspecified. ;;;###autoload (defun epa-select-keys (context prompt &optional names secret) "Display a user's keyring and ask him to select keys. -CONTEXT is an epg-context. +CONTEXT is an `epg-context'. PROMPT is a string to prompt with. NAMES is a list of strings to be matched with keys. If it is nil, all the keys are listed. @@ -968,8 +969,7 @@ For example: ;;;###autoload (defun epa-verify-cleartext-in-region (start end) - "Verify OpenPGP cleartext signed messages in the current region -between START and END. + "Verify OpenPGP cleartext signed messages in current region from START to END. Don't use this command in Lisp programs! See the reason described in the `epa-verify-region' documentation." @@ -1202,8 +1202,7 @@ If no one is selected, symmetric encryption will be performed. ") ;;;###autoload (defun epa-import-armor-in-region (start end) - "Import keys in the OpenPGP armor format in the current region -between START and END." + "Import keys in the OpenPGP armor format in the current region from START to END." (interactive "r") (save-excursion (save-restriction diff --git a/lisp/epg.el b/lisp/epg.el index 1d37cbcfb57..ea7aa869a0f 100644 --- a/lisp/epg.el +++ b/lisp/epg.el @@ -21,6 +21,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: ;;; Prelude @@ -804,7 +806,7 @@ callback data (if any)." (when (and epg-key-id (string-match "\\`passphrase\\." string)) (unless (epg-context-passphrase-callback context) - (error "passphrase-callback not set")) + (error "Variable `passphrase-callback' not set")) (let (inhibit-quit passphrase passphrase-with-new-line diff --git a/lisp/face-remap.el b/lisp/face-remap.el index c84742be5a2..50302b9682c 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -397,7 +397,7 @@ a top-level keymap, `text-scale-increase' or (defcustom buffer-face-mode-face 'variable-pitch "The face specification used by `buffer-face-mode'. It may contain any value suitable for a `face' text property, -including a face name, a list of face names, a face-attribute +including a face name, a list of face names, a face attribute plist, etc." :type '(choice (face) (repeat :tag "List of faces" face) diff --git a/lisp/faces.el b/lisp/faces.el index a5aef757b1d..7b96d938c56 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -1796,8 +1796,8 @@ If FRAME is nil, that stands for the selected frame." (defalias 'x-defined-colors 'defined-colors) (defun defined-colors-with-face-attributes (&optional frame foreground) - "Return a list of colors supported for a particular frame. -See `defined-colors' for arguments and return value. In contrast + "Return a list of colors supported for a particular FRAME. +See `defined-colors' for arguments and return value. In contrast to `defined-colors' the elements of the returned list are color strings with text properties, that make the color names render with the color they represent as background color (if FOREGROUND diff --git a/lisp/ffap.el b/lisp/ffap.el index b6e419b2d67..db380164272 100644 --- a/lisp/ffap.el +++ b/lisp/ffap.el @@ -465,11 +465,11 @@ Returned values: mesg) nil) ((string-match "not responding$" mesg) mesg) ;; v19: - ;; (file-error "connection failed" "permission denied" + ;; (file-error "Connection failed" "permission denied" ;; "nonesuch" "ffap-machine-p") - ;; (file-error "connection failed" "host is unreachable" + ;; (file-error "Connection failed" "host is unreachable" ;; "gopher.house.gov" "ffap-machine-p") - ;; (file-error "connection failed" "address already in use" + ;; (file-error "Connection failed" "address already in use" ;; "ftp.uu.net" "ffap-machine-p") ((equal mesg "connection failed") (if (string= (downcase (nth 2 error)) "permission denied") @@ -1088,8 +1088,8 @@ If a given RFC isn't in these then `ffap-rfc-path' is offered." (latex-mode "--:\\\\$+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:") (tex-mode "--:\\\\$+<>@-Z_[:alpha:]~*?" "<@" "@>;.,!:") ) - "Alist of (MODE CHARS BEG END), where MODE is a symbol, -possibly a major-mode name, or one of the symbols + "Alist of (MODE CHARS BEG END), where MODE is a symbol. +This is possibly a major-mode name, or one of the symbols `file', `url', `machine', and `nocolon'. Function `ffap-string-at-point' uses the data fields as follows: 1. find a maximal string of CHARS around point, diff --git a/lisp/fileloop.el b/lisp/fileloop.el index 45b9cea9397..cd60600a250 100644 --- a/lisp/fileloop.el +++ b/lisp/fileloop.el @@ -44,6 +44,7 @@ (defcustom fileloop-revert-buffers 'silent "Whether to revert files during fileloop operation. +This can be one of: `silent' means to only do it if `revert-without-query' is applicable; t means to offer to do it for all applicable files; nil means never to do it" diff --git a/lisp/files.el b/lisp/files.el index b113ff32f2f..2f7e936ff61 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1584,7 +1584,7 @@ Signals a `file-already-exists' error if a file of the new name already exists unless optional fourth argument OK-IF-ALREADY-EXISTS is non-nil. A number as fourth arg means request confirmation if the new name already exists. This is what happens in interactive -use with M-x." +use with \\[execute-extended-command]." (interactive (let ((default-coding (or file-name-coding-system default-file-name-coding-system)) @@ -2520,7 +2520,7 @@ Do you want to revisit the file normally now? "))) (current-buffer)))) (defun insert-file-contents-literally (filename &optional visit beg end replace) - "Like `insert-file-contents', but only reads in the file literally. + "Like `insert-file-contents', but only read in the file literally. See `insert-file-contents' for an explanation of the parameters. A buffer may be modified in several ways after reading into the buffer, due to Emacs features such as format decoding, character code diff --git a/lisp/filesets.el b/lisp/filesets.el index 63f0e8ba3ff..9182c539452 100644 --- a/lisp/filesets.el +++ b/lisp/filesets.el @@ -112,7 +112,8 @@ (defvar filesets-updated-buffers nil "A list of buffers with updated menu bars.") (defvar filesets-menu-use-cached-flag nil - "Use cached data. See `filesets-menu-ensure-use-cached' for details.") + "Non-nil means use cached data. +See `filesets-menu-ensure-use-cached' for details.") (defvar filesets-update-cache-file-flag nil "Non-nil means the cache needs updating.") (defvar filesets-ignore-next-set-default nil @@ -607,8 +608,8 @@ the filename." (:ignore-on-read-text t) ;; (:constraintp ,pic-cmd) )))) - "Alist of file patterns and external viewers for use with -`filesets-find-or-display-file'. + "Alist of file patterns and external viewers. +This is intended for use with `filesets-find-or-display-file'. Has the form ((FILE-PATTERN VIEWER PROPERTIES) ...), VIEWER being either a function or a command name as string. @@ -1770,7 +1771,7 @@ User will be queried, if no fileset name is provided." filesets-data nil))) (entry (or (assoc name filesets-data) (when (y-or-n-p - (format "Fileset %s does not exist. Create it? " + (format "Fileset %s does not exist. Create it?" name)) (progn (add-to-list 'filesets-data (list name '(:files))) @@ -2198,8 +2199,9 @@ FS is a fileset's name. FLIST is a list returned by nil)) (defun filesets-build-dir-submenu (entry lookup-name dir patt) - "Build a :tree submenu named LOOKUP-NAME with base directory DIR including -all files matching PATT for filesets ENTRY." + "Build a `:tree' submenu named LOOKUP-NAME. +It has base directory DIR including all files matching PATT for +filesets ENTRY." (let ((fd (filesets-entry-get-filter-dirs-flag entry)) (depth (or (filesets-entry-get-tree-max-level entry) filesets-tree-max-level))) diff --git a/lisp/find-dired.el b/lisp/find-dired.el index 87a7407a866..ebdb10ae9fc 100644 --- a/lisp/find-dired.el +++ b/lisp/find-dired.el @@ -266,7 +266,7 @@ it finishes, type \\[kill-find]." ;;;###autoload (defun find-name-dired (dir pattern) - "Search DIR recursively for files matching the globbing pattern PATTERN, + "Search DIR recursively for files matching the globbing PATTERN, and run Dired on those files. PATTERN is a shell wildcard (not an Emacs regexp) and need not be quoted. The default command run (after changing into DIR) is diff --git a/lisp/foldout.el b/lisp/foldout.el index cadf2746ba1..8925241df32 100644 --- a/lisp/foldout.el +++ b/lisp/foldout.el @@ -239,7 +239,7 @@ An end marker of nil means the fold ends after (point-max).") Normally the body and the immediate subheadings are exposed, but optional arg EXPOSURE \(interactively with prefix arg) changes this:- - EXPOSURE > 0 exposes n levels of subheadings (c.f. show-children) + EXPOSURE > 0 exposes n levels of subheadings (c.f. `show-children') EXPOSURE < 0 exposes only the body EXPOSURE = 0 exposes the entire subtree" (interactive "P") diff --git a/lisp/font-core.el b/lisp/font-core.el index db06a607660..95bf46c9b8b 100644 --- a/lisp/font-core.el +++ b/lisp/font-core.el @@ -21,6 +21,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: ;; This variable is used by mode packages that support Font Lock mode by diff --git a/lisp/forms.el b/lisp/forms.el index e1de0111336..551a1ba3c97 100644 --- a/lisp/forms.el +++ b/lisp/forms.el @@ -1705,7 +1705,7 @@ As a side effect: re-calculates the number of records in the data file." ;;; Other commands (defun forms-toggle-read-only (arg) - "Toggles read-only mode of a forms mode buffer. + "Toggle read-only mode of a forms mode buffer. With an argument, enables read-only mode if the argument is positive. Otherwise enables edit mode if the visited file is writable." @@ -1878,7 +1878,7 @@ after the current record." (setq forms--search-regexp regexp)) (defun forms-save-buffer (&optional args) - "Forms mode replacement for save-buffer. + "Forms mode replacement for `save-buffer'. It saves the data buffer instead of the forms buffer. Calls `forms-write-file-filter' before, and `forms-read-file-filter' after writing out the data." diff --git a/lisp/hexl.el b/lisp/hexl.el index 4a7bf9479aa..79dd5c40c69 100644 --- a/lisp/hexl.el +++ b/lisp/hexl.el @@ -1165,7 +1165,7 @@ This function is assumed to be used as callback function for `hl-line-mode'." ;; startup stuff. -(easy-menu-define hexl-menu hexl-mode-map "Hexl Mode menu" +(easy-menu-define hexl-menu hexl-mode-map "Hexl Mode menu." '("Hexl" :help "Hexl-specific Features" diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index 4c924e9d52a..7d126cb558e 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -244,7 +244,7 @@ by cycling through the faces in `hi-lock-face-defaults'." "String used to identify hi-lock patterns at the start of files.") (defvar hi-lock-archaic-interface-message-used nil - "True if user alerted that `global-hi-lock-mode' is now the global switch. + "Non-nil if user alerted that `global-hi-lock-mode' is now the global switch. Earlier versions of hi-lock used `hi-lock-mode' as the global switch; the message is issued if it appears that `hi-lock-mode' is used assuming that older functionality. This variable avoids multiple reminders.") diff --git a/lisp/image-dired.el b/lisp/image-dired.el index b92a9371ec2..3ca47300a99 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -519,7 +519,7 @@ Used by `image-dired-copy-with-exif-file-name'." (defcustom image-dired-show-all-from-dir-max-files 50 "Maximum number of files to show using `image-dired-show-all-from-dir' -before warning the user." +before warning." :type 'integer) (defmacro image-dired--with-db-file (&rest body) @@ -1958,7 +1958,7 @@ With prefix argument ARG, display image in its original size." (image-dired-display-image (dired-get-filename) arg)) (defun image-dired-image-at-point-p () - "Return true if there is an image-dired thumbnail at point." + "Return non-nil if there is an `image-dired' thumbnail at point." (get-text-property (point) 'image-dired-thumbnail)) (defun image-dired-rotate-thumbnail (degrees) diff --git a/lisp/imenu.el b/lisp/imenu.el index 788755a2d7e..22412d5f88b 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -829,8 +829,7 @@ A trivial interface to `imenu-add-to-menubar' suitable for use in a hook." (defvar imenu-buffer-menubar nil) (defvar-local imenu-menubar-modified-tick 0 - "The value of (buffer-chars-modified-tick) as of the last call -to `imenu-update-menubar'.") + "Value of (buffer-chars-modified-tick) when `imenu-update-menubar' was called.") (defun imenu-update-menubar () (when (and (current-local-map) diff --git a/lisp/indent.el b/lisp/indent.el index aa2bfbceebf..aa6b8d17c4a 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -463,7 +463,7 @@ Optional fifth argument OBJECT specifies the string or buffer to operate on." (put-text-property begin to prop (funcall func val) object)))) (defun increase-left-margin (from to inc) - "Increase or decrease the left-margin of the region. + "Increase or decrease the `left-margin' of the region. With no prefix argument, this adds `standard-indent' of indentation. A prefix arg (optional third arg INC noninteractively) specifies the amount to change the margin by, in characters. @@ -520,11 +520,14 @@ If `auto-fill-mode' is active, re-fills region to fit in new margin." (defun beginning-of-line-text (&optional n) "Move to the beginning of the text on this line. -With optional argument, move forward N-1 lines first. -From the beginning of the line, moves past the left-margin indentation, the -fill-prefix, and any indentation used for centering or right-justifying the -line, but does not move past any whitespace that was explicitly inserted -\(such as a tab used to indent the first line of a paragraph)." + +With optional argument N, move forward N-1 lines first. + +From the beginning of the line, moves past the `left-margin' +indentation, the `fill-prefix', and any indentation used for +centering or right-justifying the line, but does not move past +any whitespace that was explicitly inserted (such as a tab used +to indent the first line of a paragraph)." (interactive "^p") (beginning-of-line n) (skip-chars-forward " \t") diff --git a/lisp/info-look.el b/lisp/info-look.el index 33f15a34e99..7cc5462dd4a 100644 --- a/lisp/info-look.el +++ b/lisp/info-look.el @@ -262,7 +262,8 @@ system." (defun info-lookup-symbol (symbol &optional mode) "Display the definition of SYMBOL, as found in the relevant manual. When this command is called interactively, it reads SYMBOL from the -minibuffer. In the minibuffer, use M-n to yank the default argument +minibuffer. In the minibuffer, use \\\ +\\[next-history-element] to yank the default argument value into the minibuffer so you can edit it. The default symbol is the one found at point. @@ -276,7 +277,8 @@ With prefix arg MODE a query for the symbol help mode is offered." (defun info-lookup-file (file &optional mode) "Display the documentation of a file. When this command is called interactively, it reads FILE from the minibuffer. -In the minibuffer, use M-n to yank the default file name +In the minibuffer, use \\\ +\\[next-history-element] to yank the default file name into the minibuffer so you can edit it. The default file name is the one found at point. diff --git a/lisp/international/ccl.el b/lisp/international/ccl.el index 0eb009fa526..9be4d1ee955 100644 --- a/lisp/international/ccl.el +++ b/lisp/international/ccl.el @@ -213,8 +213,7 @@ proper index number for SYMBOL. PROP should be (ccl-embed-data (cons symbol prop))) (defun ccl-embed-string (len str) - "Embed string STR of length LEN in `ccl-program-vector' at -`ccl-current-ic'." + "Embed string STR of length LEN in `ccl-program-vector' at `ccl-current-ic'." (if (> len #xFFFFF) (error "CCL: String too long: %d" len)) (if (> (string-bytes str) len) @@ -282,8 +281,7 @@ changed to a relative jump address." (defvar ccl-loop-head nil "If non-nil, index of the start of the current loop.") (defvar ccl-breaks nil - "If non-nil, list of absolute addresses of the breaking points of -the current loop.") + "If non-nil, list of absolute addresses of breaking points of the current loop.") ;;;###autoload (defun ccl-compile (ccl-program) @@ -568,8 +566,8 @@ If READ-FLAG is non-nil, this statement has the form (cdr (cdr cmd)))) (defun ccl-compile-branch-expression (expr cmd) - "Compile EXPRESSION part of BRANCH statement and return register -which holds a value of the expression." + "Compile EXPRESSION part of BRANCH statement. +Return register which holds a value of the expression." (if (listp expr) ;; EXPR has the form `(EXPR2 OP ARG)'. Compile it as SET ;; statement of the form `(r7 = (EXPR2 OP ARG))'. @@ -1554,8 +1552,7 @@ MAP := MAP-IDs := MAP-ID ... MAP-SET := MAP-IDs | (MAP-IDs) MAP-SET -MAP-ID := integer -" +MAP-ID := integer" (declare (doc-string 3)) `(let ((prog ,(unwind-protect (progn diff --git a/lisp/international/quail.el b/lisp/international/quail.el index c0e53d26fba..50ff307b73a 100644 --- a/lisp/international/quail.el +++ b/lisp/international/quail.el @@ -471,7 +471,8 @@ conversion region is active. It is an alist of single key character vs. corresponding command to be called. If SIMPLE is non-nil, then we do not alter the meanings of -commands such as C-f, C-b, C-n, C-p and TAB; they are treated as +commands such as \\[forward-char], \\[backward-char], \\[next-line], \ +\\[previous-line] and \\[indent-for-tab-command]; they are treated as non-Quail commands." (let (translation-keymap conversion-keymap) (if deterministic (setq forget-last-selection t)) diff --git a/lisp/international/robin.el b/lisp/international/robin.el index e4a11801c38..c38cd822693 100644 --- a/lisp/international/robin.el +++ b/lisp/international/robin.el @@ -276,8 +276,7 @@ this robin package will be the following. (?c \"AC\" (?d \"ACD\") (?e \"ACE\"))) - (?b \"B\")) -") + (?b \"B\"))") ;;;###autoload (defmacro robin-define-package (name docstring &rest rules) diff --git a/lisp/isearch.el b/lisp/isearch.el index 952caa7ac22..242f2b0dd09 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -1221,7 +1221,7 @@ is processed. (It is not called after characters that exit the search.) When the arg RECURSIVE-EDIT is non-nil, this function behaves modally and does not return to the calling function until the search is completed. -To behave this way it enters a recursive-edit and exits it when done +To behave this way it enters a recursive edit and exits it when done isearching. The arg REGEXP-FUNCTION, if non-nil, should be a function. It is diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el index c1a5bbe9478..bb2df2b1ffa 100644 --- a/lisp/jit-lock.el +++ b/lisp/jit-lock.el @@ -47,7 +47,7 @@ Preserves the `buffer-modified-p' state of the current buffer." (defcustom jit-lock-chunk-size 1500 "Jit-lock fontifies chunks of at most this many characters at a time. -This variable controls both display-time and stealth fontification. +This variable controls both `display-time' and stealth fontification. The optimum value is a little over the typical number of buffer characters which fit in a typical window." diff --git a/lisp/kmacro.el b/lisp/kmacro.el index a39f433cdc3..53e6e5e288a 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -820,8 +820,8 @@ If kbd macro currently being defined end it before activating it." (defun kmacro-bind-to-key (_arg) "When not defining or executing a macro, offer to bind last macro to a key. -The key sequences [C-x C-k 0] through [C-x C-k 9] and [C-x C-k A] -through [C-x C-k Z] are reserved for user bindings, and to bind to +The key sequences `C-x C-k 0' through `C-x C-k 9' and `C-x C-k A' +through `C-x C-k Z' are reserved for user bindings, and to bind to one of these sequences, just enter the digit or letter, rather than the whole sequence. diff --git a/lisp/loadhist.el b/lisp/loadhist.el index 0b12bdad058..4a7946a212b 100644 --- a/lisp/loadhist.el +++ b/lisp/loadhist.el @@ -168,8 +168,7 @@ documentation of `unload-feature' for details.") ;; So we use this auxiliary variable to keep track of the last (t . SYMBOL) ;; that occurred. (defvar loadhist--restore-autoload nil - "If non-nil, this is a symbol for which we should -restore a previous autoload if possible.") + "If non-nil, is a symbol for which to try to restore a previous autoload.") (cl-defmethod loadhist-unload-element ((x (head t))) (setq loadhist--restore-autoload (cdr x))) diff --git a/lisp/locate.el b/lisp/locate.el index 008d65e055f..6190fc6302a 100644 --- a/lisp/locate.el +++ b/lisp/locate.el @@ -50,7 +50,7 @@ ;; from a shell prompt. GNU locate and BSD find expect the file databases ;; to either be in standard places or located via environment variables. ;; If the latter, make sure these environment variables are set in -;; your emacs process. +;; your Emacs process. ;; ;; Locate-mode assumes that each line output from the locate-command ;; consists exactly of a file name, possibly preceded or trailed by diff --git a/lisp/macros.el b/lisp/macros.el index 689c4210cd7..89e38abab2d 100644 --- a/lisp/macros.el +++ b/lisp/macros.el @@ -148,11 +148,16 @@ use this command, and then save the file." ;;;###autoload (defun kbd-macro-query (flag) "Query user during kbd macro execution. - With prefix argument, enters recursive edit, reading keyboard -commands even within a kbd macro. You can give different commands -each time the macro executes. - Without prefix argument, asks whether to continue running the macro. + +With prefix argument FLAG, enter recursive edit, reading +keyboard commands even within a kbd macro. You can give +different commands each time the macro executes. + +Without prefix argument, ask whether to continue running the +macro. + Your options are: \\ + \\[act] Finish this iteration normally and continue with the next. \\[skip] Skip the rest of this iteration, and start the next. \\[exit] Stop the macro entirely right now. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 07f7beb92c8..e84eec5002c 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -2156,7 +2156,7 @@ otherwise it could decide to silently do nothing." (> count 1))) (defcustom yank-menu-length 20 - "Maximum length to display in the yank-menu." + "Maximum length to display in the `yank-menu'." :type 'integer :group 'menu) @@ -2289,7 +2289,7 @@ Buffers menu is regenerated." It must accept a buffer as its only required argument.") (defun menu-bar-buffer-vector (alist) - ;; turn ((name . buffer) ...) into a menu + "Turn ((name . buffer) ...) into a menu." (let ((buffers-vec (make-vector (length alist) nil)) (i (length alist))) (dolist (pair alist) @@ -2303,7 +2303,7 @@ It must accept a buffer as its only required argument.") buffers-vec)) (defun menu-bar-update-buffers (&optional force) - ;; If user discards the Buffers item, play along. + "If user discards the Buffers item, play along." (and (lookup-key (current-global-map) [menu-bar buffer]) (or force (frame-or-buffer-changed-p)) (let ((buffers (buffer-list)) diff --git a/lisp/mouse-drag.el b/lisp/mouse-drag.el index b424b6edfe8..ecfb359b36f 100644 --- a/lisp/mouse-drag.el +++ b/lisp/mouse-drag.el @@ -147,7 +147,7 @@ Keep the cursor on the screen as needed." (= (cdr start-col-row) (cdr end-col-row))))) (defvar mouse-drag-electric-col-scrolling t - "If non-nil, mouse-drag on a long line enables truncate-lines.") + "If non-nil, mouse-drag on a long line enables `truncate-lines'.") (defun mouse-drag-should-do-col-scrolling () "Determine if it's wise to enable col-scrolling for the current window. diff --git a/lisp/mouse.el b/lisp/mouse.el index edac5085ff8..41333eb7f71 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -46,7 +46,7 @@ :type 'boolean) (defcustom mouse-drag-copy-region nil - "If non-nil, copy to kill-ring upon mouse adjustments of the region. + "If non-nil, copy to kill ring upon mouse adjustments of the region. This affects `mouse-save-then-kill' (\\[mouse-save-then-kill]) in addition to mouse drags. diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index c5c9dfb2afc..98ce1d6993e 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -455,8 +455,9 @@ reference.") ;; because Emacs turns C-c C-i into C-c TAB which is hard to type and ;; not mnemonic. "Major mode for editing XML. - +\\ \\[nxml-finish-element] finishes the current element by inserting an end-tag. + C-c C-i closes a start-tag with `>' and then inserts a balancing end-tag leaving point between the start-tag and end-tag. \\[nxml-balanced-close-start-tag-block] is similar but for block rather than inline elements: diff --git a/lisp/nxml/rng-loc.el b/lisp/nxml/rng-loc.el index a38da794226..c8b19e8c229 100644 --- a/lisp/nxml/rng-loc.el +++ b/lisp/nxml/rng-loc.el @@ -501,7 +501,7 @@ saved to the first writable file in `rng-schema-locating-files'." nil (error "Buffer does not have a filename"))) ((and prompt - (not (y-or-n-p (format "Save %s to %s " + (not (y-or-n-p (format "Save %s to %s?" (if type-id "type identifier" "schema location") @@ -539,7 +539,7 @@ saved to the first writable file in `rng-schema-locating-files'." locating-file-uri)))))) (indent-according-to-mode) (when (or (not modified) - (y-or-n-p (format "Save file %s " + (y-or-n-p (format "Save file %s?" (buffer-file-name)))) (save-buffer)))))))) diff --git a/lisp/nxml/rng-valid.el b/lisp/nxml/rng-valid.el index fca666115a2..9df20a16b1d 100644 --- a/lisp/nxml/rng-valid.el +++ b/lisp/nxml/rng-valid.el @@ -962,9 +962,8 @@ Return nil at end of buffer, t otherwise." (and type t))) (defun rng-process-start-tag (tag-type) - "TAG-TYPE is `start-tag' for a start-tag, `empty-element' for -an empty element. `partial-empty-element' should be passed -as empty-element." + "TAG-TYPE is `start-tag' for a start-tag, `empty-element' for an empty element. +`partial-empty-element' should be passed as empty-element." (and rng-collecting-text (rng-flush-text)) (setq rng-collecting-text nil) (setq rng-pending-contents nil) diff --git a/lisp/pcmpl-x.el b/lisp/pcmpl-x.el index fd147101b69..d9479edf6a6 100644 --- a/lisp/pcmpl-x.el +++ b/lisp/pcmpl-x.el @@ -21,6 +21,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: (eval-when-compile (require 'cl-lib)) diff --git a/lisp/play/5x5.el b/lisp/play/5x5.el index 1d193306296..085c97f5d8e 100644 --- a/lisp/play/5x5.el +++ b/lisp/play/5x5.el @@ -387,7 +387,7 @@ Mutate the result." (defun 5x5-crack (breeder) "Attempt to find a solution for 5x5. -5x5-crack takes the argument BREEDER which should be a function that takes +`5x5-crack' takes the argument BREEDER which should be a function that takes two parameters, the first will be a grid vector array that is the current solution and the second will be the best solution so far. The function should return a grid vector array that is the new solution." @@ -474,8 +474,8 @@ position." grid))) (defun 5x5-vec-to-grid (grid-matrix) - "Convert a grid matrix GRID-MATRIX in Calc format to a grid in -5x5 format. See function `5x5-grid-to-vec'." + "Convert a grid matrix GRID-MATRIX in Calc format to a grid in 5x5 format. +See function `5x5-grid-to-vec'." (apply #'vector (mapcar diff --git a/lisp/play/doctor.el b/lisp/play/doctor.el index 9777fc3ea24..b855f7e35a1 100644 --- a/lisp/play/doctor.el +++ b/lisp/play/doctor.el @@ -115,7 +115,7 @@ (defun doc// (x) x) (defmacro doc$ (what) - "Quoted arg form of doctor-$." + "Quoted arg form of `doctor-$'." `(doctor-$ ',what)) (defun doctor-$ (what) @@ -1011,7 +1011,7 @@ Put dialogue in buffer." (defun doctor-subjsearch (sent key type) "Search for the subject of a sentence SENT, looking for the noun closest -to and preceding KEY by at least TYPE words. Set global variable doctor-subj to +to and preceding KEY by at least TYPE words. Set global variable `doctor-subj' to the subject noun, and return the portion of the sentence following it." (let ((i (- (length sent) (length (memq key sent)) type))) (while (and (> i -1) (not (doctor-nounp (nth i sent)))) diff --git a/lisp/play/dunnet.el b/lisp/play/dunnet.el index d9acad8e43e..706c1be81e0 100644 --- a/lisp/play/dunnet.el +++ b/lisp/play/dunnet.el @@ -944,8 +944,8 @@ handled specially by 'dun-describe-room.") (list obj-pc) ;; pc-area nil nil nil nil nil nil ) - "These are objects in a room that are only described in the -room description. They are permanent.") + "These are objects in a room that are only described in the room description. +They are permanent.") (defvar dun-inventory '(1)) (defconst dun-objects @@ -1010,8 +1010,7 @@ the inventory.") nil nil ("There is a bus here.") nil nil nil) - "These are the descriptions for the negative numbered objects from -`dun-room-objects'.") + "Descriptions for the negative numbered objects from `dun-room-objects'.") (defconst dun-physobj-desc '( @@ -1216,8 +1215,9 @@ Otherwise short. Also give long if we were called with negative room number." (dun-mprincl "You are on the bus.")))) (defun dun-special-object () - "There is a special object in the room. This object's description, -or lack thereof, depends on certain conditions." + "There is a special object in the room. +This object's description, or lack thereof, depends on certain +conditions." (cond ((= dun-current-room computer-room) (if dun-computer diff --git a/lisp/play/hanoi.el b/lisp/play/hanoi.el index d3d0ad1309c..227dd790af5 100644 --- a/lisp/play/hanoi.el +++ b/lisp/play/hanoi.el @@ -133,7 +133,7 @@ Repent before ring 31 moves." (defun hanoi-unix-64 () "Like `hanoi-unix', but pretend to have a 64-bit clock. This is, necessarily (as of Emacs 20.3), a crock. When the -current-time interface is made s2G-compliant, hanoi.el will need +`current-time' interface is made s2G-compliant, hanoi.el will need to be updated." (interactive) (let* ((start (ftruncate (float-time))) diff --git a/lisp/play/mpuz.el b/lisp/play/mpuz.el index 5ac1d7c60c2..ff174fed6c2 100644 --- a/lisp/play/mpuz.el +++ b/lisp/play/mpuz.el @@ -119,7 +119,7 @@ You may abort a game by typing \\\\[mpuz-offer-abort]." ;; Some variables for game tracking ;;--------------------------------- (defvar mpuz-in-progress nil - "True if a game is currently in progress.") + "Non-nil if a game is currently in progress.") (defvar mpuz-found-digits (make-bool-vector 10 nil) "A vector recording which digits have been decrypted.") diff --git a/lisp/play/tetris.el b/lisp/play/tetris.el index f43aa47326f..3d6ddd5307f 100644 --- a/lisp/play/tetris.el +++ b/lisp/play/tetris.el @@ -620,7 +620,7 @@ Shapes drop from the top of the screen, and the user has to move and rotate the shape to fit in with those at the bottom of the screen so as to form complete rows. -tetris-mode keybindings: +`tetris-mode' keybindings: \\ \\[tetris-start-game] Start a new game of Tetris \\[tetris-end-game] Terminate the current game diff --git a/lisp/printing.el b/lisp/printing.el index 89e49ccb2a4..fb718f9aa62 100644 --- a/lisp/printing.el +++ b/lisp/printing.el @@ -1672,7 +1672,7 @@ DEFAULT It's a way to set default values when this entry is selected. (set VARIABLE (eval VALUE)) - Note that VALUE can be any valid lisp expression. So, don't + Note that VALUE can be any valid Lisp expression. So, don't forget to quote symbols and constant lists. If VARIABLE is the special keyword `inherits-from:', VALUE must be a symbol name setting defined in `pr-setting-database' from @@ -1772,8 +1772,7 @@ Useful links: `https://linux.die.net/man/1/lp' * GNU utilities for w32 (cp.exe) - `http://unxutils.sourceforge.net/' -" + `http://unxutils.sourceforge.net/'" :type '(repeat (list :tag "PostScript Printer" @@ -2181,7 +2180,7 @@ DEFAULT It's a way to set default values when this entry is selected. (set (make-local-variable VARIABLE-SYM) (eval VALUE)) - Note that VALUE can be any valid lisp expression. So, don't + Note that VALUE can be any valid Lisp expression. So, don't forget to quote symbols and constant lists. If VARIABLE is the special keyword `inherits-from:', VALUE must be a symbol name setting defined in `pr-setting-database' from @@ -2413,8 +2412,7 @@ Useful links: * GNU Enscript documentation (Windows, GNU or Unix) `https://people.ssh.com/mtr/genscript/enscript.man.html' - (on GNU or Unix, type `man enscript') -" + (on GNU or Unix, type `man enscript')" :type '(repeat (list :tag "PS File Utility" (symbol :tag "Utility Symbol") @@ -4276,7 +4274,7 @@ printed using `pr-ps-mode-ps-print'. Interactively, you have the following situations: - M-x pr-ps-fast-fire RET + \\[pr-ps-fast-fire] The command prompts the user for a N-UP value and printing will immediately be done using the current active printer. diff --git a/lisp/profiler.el b/lisp/profiler.el index 0b456bb3e31..fa74fe8de25 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -105,8 +105,8 @@ ;;; Entries (defun profiler-format-entry (entry) - "Format ENTRY in human readable string. ENTRY would be a -function name of a function itself." + "Format ENTRY in human readable string. +ENTRY would be a function name of a function itself." (cond ((memq (car-safe entry) '(closure lambda)) (format "#" (sxhash entry))) ((byte-code-function-p entry) @@ -463,7 +463,7 @@ Optional argument MODE means only check for the specified mode (cpu or mem)." "The current profile.") (defvar-local profiler-report-reversed nil - "True if calltree is rendered in bottom-up. + "Non-nil if calltree is rendered in bottom-up. Do not touch this variable directly.") (defvar-local profiler-report-order nil diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el index f07f18678a2..b6805898b0e 100644 --- a/lisp/progmodes/cc-bytecomp.el +++ b/lisp/progmodes/cc-bytecomp.el @@ -339,8 +339,8 @@ should be a string. CONDITION should not be quoted." '(progn))) (defmacro cc-provide (feature) - "A replacement for the `provide' form that restores the environment -after the compilation. Don't use within `eval-when-compile'." + "A replacement for `provide' that restores the environment after the compilation. +Don't use within `eval-when-compile'." (declare (debug t)) `(progn (eval-when-compile (cc-bytecomp-restore-environment)) @@ -381,8 +381,9 @@ afterwards. Don't use within `eval-when-compile'." (eval-when-compile (cc-bytecomp-setup-environment)))) (defmacro cc-bytecomp-defvar (var) - "Bind the symbol as a variable during compilation of the file, -to silence the byte compiler. Don't use within `eval-when-compile'." + "Bind the symbol VAR as a variable during compilation of the file. +This can be used to silence the byte compiler. Don't use within +`eval-when-compile'." (declare (debug nil)) `(eval-when-compile (if (boundp ',var) @@ -403,8 +404,9 @@ to silence the byte compiler. Don't use within `eval-when-compile'." "cc-bytecomp-defvar: Covered variable %s" ',var)))))) (defmacro cc-bytecomp-defun (fun) - "Bind the symbol as a function during compilation of the file, -to silence the byte compiler. Don't use within `eval-when-compile'. + "Bind the symbol FUN as a function during compilation of the file. +This can be used to silence the byte compiler. Don't use within +`eval-when-compile'. If the symbol already is bound as a function, it will keep that definition. That means that this macro will not shut up warnings @@ -431,8 +433,8 @@ at compile time, e.g. for macros and inline functions." "cc-bytecomp-defun: Covered function %s" ',fun)))))) (defmacro cc-bytecomp-put (symbol propname value) - "Set a property on a symbol during compilation (and evaluation) of -the file. Don't use outside `eval-when-compile'." + "Set a property on SYMBOL during compilation (and evaluation) of the file. +Don't use outside `eval-when-compile'." (declare (debug t)) `(eval-when-compile (if (not (assoc (cons ,symbol ,propname) cc-bytecomp-original-properties)) @@ -450,9 +452,9 @@ the file. Don't use outside `eval-when-compile'." ,propname ,symbol ,value))) (defmacro cc-bytecomp-boundp (symbol) - "Return non-nil if the given symbol is bound as a variable outside -the compilation. This is the same as using `boundp' but additionally -exclude any variables that have been bound during compilation with + "Return non-nil if SYMBOL is bound as a variable outside the compilation. +This is the same as using `boundp' but additionally exclude any +variables that have been bound during compilation with `cc-bytecomp-defvar'." (declare (debug t)) (if (and (cc-bytecomp-is-compiling) @@ -461,9 +463,9 @@ exclude any variables that have been bound during compilation with `(boundp ,symbol))) (defmacro cc-bytecomp-fboundp (symbol) - "Return non-nil if the given symbol is bound as a function outside -the compilation. This is the same as using `fboundp' but additionally -exclude any functions that have been bound during compilation with + "Return non-nil if SYMBOL is bound as a function outside the compilation. +This is the same as using `fboundp' but additionally exclude any +functions that have been bound during compilation with `cc-bytecomp-defun'." (declare (debug t)) (let (fun-elem) diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 217281b8a24..6c3da667bfc 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -5113,8 +5113,9 @@ inside a preprocessor directive." (defun c-context-open-line () "Insert a line break suitable to the context and leave point before it. -This is the `c-context-line-break' equivalent to `open-line', which is -normally bound to C-o. See `c-context-line-break' for the details." +This is the `c-context-line-break' equivalent to `open-line' +\(bound to \\[open-line]). See `c-context-line-break' for the +details." (interactive "*") (let ((here (point))) (unwind-protect diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index be0b40fd6c2..12e10c26eec 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -827,9 +827,9 @@ right side of it." ;; impossible to get a feel for how that function works. (defmacro c-go-list-forward (&optional pos limit) - "Move forward across one balanced group of parentheses starting at POS or -point. Return POINT when we succeed, NIL when we fail. In the latter case, -leave point unmoved. + "Move forward across one balanced group of parentheses starting at POS or point. +Return POINT when we succeed, NIL when we fail. In the latter +case, leave point unmoved. A LIMIT for the search may be given. The start position is assumed to be before it." @@ -838,9 +838,9 @@ before it." (when dest (goto-char dest) dest))) (defmacro c-go-list-backward (&optional pos limit) - "Move backward across one balanced group of parentheses starting at POS or -point. Return POINT when we succeed, NIL when we fail. In the latter case, -leave point unmoved. + "Move backward across one balanced group of parentheses starting at POS or point. +Return POINT when we succeed, NIL when we fail. In the latter +case, leave point unmoved. A LIMIT for the search may be given. The start position is assumed to be after it." @@ -2593,7 +2593,7 @@ quoted." (defvar c-lang-constants-under-evaluation nil "Alist of constants in the process of being evaluated. The `cdr' of each entry indicates how far we've looked in the list -of definitions, so that the def for var FOO in c-mode can be defined in +of definitions, so that the def for var FOO in `c-mode' can be defined in terms of the def for that same var FOO (which will then rely on the fallback definition for all modes, to break the cycle).") diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 53c382f018c..20cdb72ccf1 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -1545,7 +1545,7 @@ comment at the start of cc-engine.el for more info." nil)))))) (defun c-at-statement-start-p () - "Return non-nil if the point is at the first token in a statement + "Return non-nil if point is at the first token in a statement or somewhere in the syntactic whitespace before it. A \"statement\" here is not restricted to those inside code blocks. @@ -1574,7 +1574,7 @@ comment at the start of cc-engine.el for more info." (c-crosses-statement-barrier-p (point) end))))) (defun c-at-expression-start-p () - "Return non-nil if the point is at the first token in an expression or + "Return non-nil if point is at the first token in an expression or statement, or somewhere in the syntactic whitespace before it. An \"expression\" here is a bit different from the normal language @@ -4969,7 +4969,7 @@ out of an enclosing paren." nil)))) (defun c-forward-over-token-and-ws (&optional balanced) - "Move forward over a token and any following whitespace + "Move forward over a token and any following whitespace. Return t if we moved, nil otherwise (i.e. we were at EOB, or a non-token or BALANCED is non-nil and we can't move). If we are at syntactic whitespace, move over this in place of a token. @@ -5384,8 +5384,8 @@ comment at the start of cc-engine.el for more info." (defvar safe-pos-list) ; bound in c-syntactic-skip-backward (defun c-syntactic-skip-backward (skip-chars &optional limit paren-level) - "Like `skip-chars-backward' but only look at syntactically relevant chars, -i.e. don't stop at positions inside syntactic whitespace or string + "Like `skip-chars-backward' but only look at syntactically relevant chars. +This means don't stop at positions inside syntactic whitespace or string literals. Preprocessor directives are also ignored, with the exception of the one that the point starts within, if any. If LIMIT is given, it's assumed to be at a syntactically relevant position. diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 7e7053b98e1..bc0ae6cc95a 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -1765,7 +1765,7 @@ casts and declarations are fontified. Used on level 2 and higher." (> (match-beginning 0) (point-min)) (memq (c-get-char-property (1- (match-beginning 0)) 'face) '(font-lock-comment-face font-lock-string-face - font-lock-comment-delimiter-face)))) + font-lock-comment-delimiter-face)))) (when found (setq open-delim (cons (match-beginning 1) (cons (match-end 1) (match-beginning 2))) diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index b106454b11e..36f12369fca 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -4178,8 +4178,7 @@ aliases in Emacs are resolved." (cdr c-emacs-variable-inits)))) (defun c-make-init-lang-vars-fun (mode) - "Create a function that initializes all the language dependent variables -for the given mode. + "Create a function that initializes all language dependent variables for MODE. This function should be evaluated at compile time, so that the function it returns is byte compiled with all the evaluated results diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index c818c1a3582..8b302414496 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -1648,7 +1648,7 @@ Note that the style variables are always made local to the buffer." (and (memq (char-before) c-string-delims) (not (nth 4 s))))) ; Check we're actually out of the ; comment. not stuck at EOB - (unless + (unless (and c-ml-string-opener-re (c-maybe-re-mark-ml-string)) (if (c-unescaped-nls-in-string-p (1- (point))) diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index dcd9546d9aa..8869c565737 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el @@ -1227,7 +1227,7 @@ can always override the use of `c-default-style' by making calls to ;; Anchor pos: None. )) (defcustom c-offsets-alist nil - "Association list of syntactic element symbols and indentation offsets. + "Alist of syntactic element symbols and indentation offsets. As described below, each cons cell in this list has the form: (SYNTACTIC-SYMBOL . OFFSET) diff --git a/lisp/progmodes/cmacexp.el b/lisp/progmodes/cmacexp.el index 0f7c8c6f31a..07648ac623c 100644 --- a/lisp/progmodes/cmacexp.el +++ b/lisp/progmodes/cmacexp.el @@ -101,7 +101,7 @@ :type 'boolean) (defcustom c-macro-prompt-flag nil - "Non-nil makes `c-macro-expand' prompt for preprocessor arguments." + "Non-nil means `c-macro-expand' will prompt for preprocessor arguments." :type 'boolean) (defcustom c-macro-preprocessor diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 6b521e8d90b..73f98068110 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -687,11 +687,13 @@ matched file names, and weeding out false positives." ,(expand-file-name "compilation.txt" data-directory))) (defvar compilation-error-case-fold-search nil - "If non-nil, use case-insensitive matching of compilation errors -by the regexps of `compilation-error-regexp-alist' and -`compilation-error-regexp-alist-alist'. + "If non-nil, use case-insensitive matching of compilation errors. If nil, matching is case-sensitive. +Compilation errors are given by the regexps in +`compilation-error-regexp-alist' and +`compilation-error-regexp-alist-alist'. + This variable should only be set for backward compatibility as a temporary measure. The proper solution is to use a regexp that matches the messages without case-folding.") diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 634dd29bad6..c371a84b9d2 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -361,14 +361,14 @@ Affects: `cperl-font-lock', `cperl-electric-lbrace-space', ;; :group 'cperl) (defcustom cperl-info-on-command-no-prompt nil - "Not-nil (and non-null) means not to prompt on C-h f. + "Not-nil (and non-null) means not to prompt on \\[cperl-info-on-command]. The opposite behavior is always available if prefixed with C-c. Can be overwritten by `cperl-hairy' if nil." :type '(choice (const null) boolean) :group 'cperl-affected-by-hairy) (defcustom cperl-clobber-lisp-bindings nil - "Not-nil (and non-null) means not overwrite C-h f. + "Not-nil (and non-null) means not overwrite \\[describe-function]. The function is available on \\[cperl-info-on-command], \\[cperl-get-help]. Can be overwritten by `cperl-hairy' if nil." :type '(choice (const null) boolean) diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el index 6602a79b2a4..d800365e66d 100644 --- a/lisp/progmodes/cpp.el +++ b/lisp/progmodes/cpp.el @@ -711,8 +711,8 @@ BRANCH should be either nil (false branch), t (true branch) or `both'." default)) (defun cpp-choose-default-face (type) - ;; Choose default face list for screen of TYPE. - ;; Type must be one of the types defined in `cpp-face-type-list'. + "Choose default face list for screen of TYPE. +Type must be one of the types defined in `cpp-face-type-list'." (interactive (list (if cpp-button-event (x-popup-menu cpp-button-event (list "Screen type" @@ -789,7 +789,7 @@ BRANCH should be either nil (false branch), t (true branch) or `both'." (if data (list 'cpp-data data)))))) (defun cpp-push-button (event) - ;; Pushed a CPP button. + "Pushed a CPP button." (interactive "@e") (set-buffer (window-buffer (posn-window (event-start event)))) (let ((pos (posn-point (event-start event)))) diff --git a/lisp/progmodes/dcl-mode.el b/lisp/progmodes/dcl-mode.el index ed024f24344..b74b558f8df 100644 --- a/lisp/progmodes/dcl-mode.el +++ b/lisp/progmodes/dcl-mode.el @@ -494,7 +494,7 @@ Variables controlling indentation style and extra features: These variables control the look of expanded templates. dcl-imenu-generic-expression - Default value for imenu-generic-expression. The default includes + Default value for `imenu-generic-expression'. The default includes SUBROUTINE labels in the main listing and sub-listings for other labels, CALL, GOTO and GOSUB statements. @@ -1463,7 +1463,7 @@ Inserts continuation marks and splits character strings." ;;;------------------------------------------------------------------------- (defun dcl-delete-indentation (&optional arg) - "Join this line to previous like delete-indentation. + "Join this line to previous like `delete-indentation'. Also remove the continuation mark if easily detected." (interactive "*P") (delete-indentation arg) diff --git a/lisp/progmodes/ebnf-yac.el b/lisp/progmodes/ebnf-yac.el index 816cc432d1b..84950e45f51 100644 --- a/lisp/progmodes/ebnf-yac.el +++ b/lisp/progmodes/ebnf-yac.el @@ -113,7 +113,7 @@ ;;; YACC-Code = "any C definition". (defun ebnf-yac-parser (start) - "yacc/Bison parser." + "Yacc/Bison parser." (let ((total (+ (- ebnf-limit start) 1)) (bias (1- start)) (origin (point)) diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 3f2c9b71485..f9e6101e7ab 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el @@ -65,8 +65,8 @@ ;; the variable f90-comment-region in every line of the region. ;; One common convention for free vs. fixed format is that free format -;; files have the ending .f90 or .f95 while fixed format files have -;; the ending .f. Emacs automatically loads Fortran files in the +;; files have the ending ".f90" or ".f95" while fixed format files have +;; the ending ".f". Emacs automatically loads Fortran files in the ;; appropriate mode based on extension. You can modify this by ;; adjusting the variable `auto-mode-alist'. ;; For example: @@ -984,7 +984,7 @@ Used in the F90 entry in `hs-special-modes-alist'.") ;; FIXME trivial to extend this to enum. Worth it? (defun f90-imenu-type-matcher () "Search backward for the start of a derived type. -Set subexpression 1 in the match-data to the name of the type." +Set subexpression 1 in the `match-data' to the name of the type." (let (found) (while (and (re-search-backward "^[ \t0-9]*type[ \t]*" nil t) (not (setq found diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index e8ce0e723e4..9418debe5e3 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -559,7 +559,7 @@ Currently accepted REPORT-KEY arguments are: (put :warning 'flymake-category 'flymake-warning) (put :note 'flymake-category 'flymake-note) -(defvar flymake-diagnostic-types-alist '() "") +(defvar flymake-diagnostic-types-alist '()) (make-obsolete-variable 'flymake-diagnostic-types-alist "Set properties on the diagnostic symbols instead. See Info @@ -1329,7 +1329,7 @@ default) no filter is applied." ;;; Mode-line and menu ;;; -(easy-menu-define flymake-menu flymake-mode-map "Flymake" +(easy-menu-define flymake-menu flymake-mode-map "Flymake menu." '("Flymake" [ "Go to next problem" flymake-goto-next-error t ] [ "Go to previous problem" flymake-goto-prev-error t ] diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 902466e4feb..3e5b8e2f32b 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -467,8 +467,8 @@ GDB session needs to be restarted for this setting to take effect." ;; TODO Some commands can't be called with --all (give a notice about ;; it in setting doc) (defcustom gdb-gud-control-all-threads t - "When non-nil, GUD execution commands affect all threads when -in non-stop mode. Otherwise, only current thread is affected." + "When non-nil, GUD execution commands affect all threads when in non-stop mode. +Otherwise, only current thread is affected." :type 'boolean :group 'gdb-non-stop :version "23.2") @@ -1483,7 +1483,7 @@ INDENT is the current indentation depth." (expr (nth 1 var)) (children (nth 2 var))) (if (or (<= (string-to-number children) gdb-max-children) (y-or-n-p - (format "%s has %s children. Continue? " expr children))) + (format "%s has %s children. Continue?" expr children))) (gdb-var-list-children token)))) ((string-search "-" text) ;contract this node (dolist (var gdb-var-list) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index d7f4582dd0b..ec2850737c8 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -72,7 +72,7 @@ SYMBOL should be one of `grep-command', `grep-template', Some grep programs are able to surround matches with special markers in grep output. Such markers can be used to highlight matches in grep mode. This requires `font-lock-mode' to be active -in grep buffers, so if you have globally disabled font-lock-mode, +in grep buffers, so if you have globally disabled `font-lock-mode', you will not get highlighting. This option sets the environment variable GREP_COLORS to specify @@ -137,7 +137,7 @@ The following place holders should be present in the string: - file names and wildcards to search. - file names and wildcards to exclude. - the regular expression searched for. - - place to insert null-device. + - place to insert `null-device'. In interactive usage, the actual value of this variable is set up by `grep-compute-defaults'; to change the default value, use diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index b2557587c6c..e2ad480281f 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -62,7 +62,7 @@ ;; activated or deactivated, `hs-minor-mode-hook' is run w/ `run-hooks'. ;; ;; Additionally, Joseph Eydelnant writes: -;; I enjoy your package hideshow.el Ver. 5.24 2001/02/13 +;; I enjoy your package hideshow.el Version 5.24 2001/02/13 ;; a lot and I've been looking for the following functionality: ;; toggle hide/show all with a single key. ;; Here are a few lines of code that lets me do just that. diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index 36f8a6d6b6e..d6828eeffbb 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el @@ -5316,7 +5316,7 @@ directories and save the routine info. (defun idlwave-delete-user-catalog-file (&rest _ignore) (if (yes-or-no-p - (format "Delete file %s " idlwave-user-catalog-file)) + (format "Delete file %s?" idlwave-user-catalog-file)) (progn (delete-file idlwave-user-catalog-file) (message "%s has been deleted" idlwave-user-catalog-file)))) diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el index 51c888d25f3..e55b09d8fcf 100644 --- a/lisp/progmodes/opascal.el +++ b/lisp/progmodes/opascal.el @@ -51,7 +51,7 @@ :group 'languages) (defconst opascal-debug nil - "True if in debug mode.") + "Non-nil if in debug mode.") (define-obsolete-variable-alias 'delphi-search-path 'opascal-search-path "24.4") @@ -1732,7 +1732,8 @@ comment block. If not in a // comment, just does a normal newline." (define-obsolete-function-alias 'delphi-mode #'opascal-mode "24.4") ;;;###autoload (define-derived-mode opascal-mode prog-mode "OPascal" - "Major mode for editing OPascal code.\\ + "Major mode for editing OPascal code. +\\ \\[opascal-find-unit]\t- Search for a OPascal source file. \\[opascal-fill-comment]\t- Fill the current comment. \\[opascal-new-comment-line]\t- If in a // comment, do a new comment line. diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 7f70e02b72e..6c09dcf881d 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -127,7 +127,7 @@ which case it will be used to compose the new symbol as per the third argument of `compose-region'.") (defun prettify-symbols-default-compose-p (start end _match) - "Return true iff the symbol MATCH should be composed. + "Return non-nil iff the symbol MATCH should be composed. The symbol starts at position START and ends at position END. This is the default for `prettify-symbols-compose-predicate' which is suitable for most programming languages such as C or Lisp." @@ -145,7 +145,7 @@ which is suitable for most programming languages such as C or Lisp." "A predicate for deciding if the currently matched symbol is to be composed. The matched symbol is the car of one entry in `prettify-symbols-alist'. The predicate receives the match's start and end positions as well -as the match-string as arguments.") +as the `match-string' as arguments.") (defun prettify-symbols--compose-symbol (alist) "Compose a sequence of characters into a symbol. diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 2eead0d0696..9b63f4b1bc8 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1033,8 +1033,8 @@ command \\[fileloop-continue]." (defun project-query-replace-regexp (from to) "Query-replace REGEXP in all the files of the project. Stops when a match is found and prompts for whether to replace it. -If you exit the query-replace, you can later continue the query-replace -loop using the command \\[fileloop-continue]." +If you exit the `query-replace', you can later continue the +`query-replace' loop using the command \\[fileloop-continue]." (interactive (pcase-let ((`(,from ,to) (query-replace-read-args "Query replace (regexp)" t t))) diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index d47bb8bcb96..dabf9c479e2 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el @@ -414,7 +414,7 @@ wherever possible, since it is slow." ;; "----" ["MB" nil :help "Help MB"])) (defun verilog-define-abbrev-table (tablename definitions &optional docstring &rest props) - "Filter `define-abbrev-table' TABLENAME DEFINITIONS + "Filter `define-abbrev-table' TABLENAME DEFINITIONS. Provides DOCSTRING PROPS in newer Emacs (23.1)." (condition-case nil (apply #'define-abbrev-table tablename definitions docstring props) @@ -13380,7 +13380,7 @@ Typing \\[verilog-auto] will call my-verilog-insert-hello and expand the above into: /*AUTOINSERTLISP(my-verilog-insert-hello \"world\")*/ - // Beginning of automatic insert lisp + // Beginning of automatic insert Lisp initial $write(\"hello world\"); // End of automatics diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el index fef7dff65e2..fc0d406f73c 100644 --- a/lisp/progmodes/vhdl-mode.el +++ b/lisp/progmodes/vhdl-mode.el @@ -2197,8 +2197,8 @@ is pair matching KEY." (setq alist alist-cdr))))) (defun vhdl-aget (alist key) - "Return the value in ALIST that is associated with KEY. If KEY is -not found, then nil is returned." + "Return the value in ALIST that is associated with KEY. +If KEY is not found, then nil is returned." (cdr (assoc key alist))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -4275,8 +4275,7 @@ STRING are replaced by `-' and substrings are converted to lower case." (defvar vhdl-sources-menu nil) (defun vhdl-directory-files (directory &optional full match) - "Call `directory-files' if DIRECTORY exists, otherwise generate error -message." + "Call `directory-files' if DIRECTORY exists, otherwise generate error message." (if (not (file-directory-p directory)) (vhdl-warning-when-idle "No such directory: \"%s\"" directory) (let ((dir (directory-files directory full match))) @@ -5734,8 +5733,8 @@ the offset is simply returned." (save-excursion (re-search-forward "\\\\" (vhdl-point 'eol) t))))) (defun vhdl-forward-comment (&optional direction) - "Skip all comments (including whitespace). Skip backwards if DIRECTION is -negative, skip forward otherwise." + "Skip all comments (including whitespace). +Skip backwards if DIRECTION is negative, skip forward otherwise." (interactive "p") (if (and direction (< direction 0)) ;; skip backwards @@ -6912,9 +6911,9 @@ previous libunit keyword)." (concat vhdl-case-alternative-re "\\|" vhdl-case-header-key)) (defun vhdl-skip-case-alternative (&optional lim) - "Skip forward over case/when bodies, with optional maximal -limit. If no next case alternative is found, nil is returned and -point is not moved." + "Skip forward over case/when bodies, with optional maximal limit. +If no next case alternative is found, nil is returned and point +is not moved." (let ((lim (or lim (point-max))) (here (point)) donep foundp) @@ -6939,9 +6938,8 @@ point is not moved." foundp)) (defun vhdl-backward-skip-label (&optional lim) - "Skip backward over a label, with optional maximal -limit. If label is not found, nil is returned and point -is not moved." + "Skip backward over a label, with optional maximal limit. +If label is not found, nil is returned and point is not moved." (let ((lim (or lim (point-min))) placeholder) (if (save-excursion @@ -6955,9 +6953,8 @@ is not moved." )) (defun vhdl-forward-skip-label (&optional lim) - "Skip forward over a label, with optional maximal -limit. If label is not found, nil is returned and point -is not moved." + "Skip forward over a label, with optional maximal limit. +If label is not found, nil is returned and point is not moved." (let ((lim (or lim (point-max)))) (if (looking-at vhdl-label-key) (progn @@ -7327,9 +7324,9 @@ after the containing paren which starts the arglist." (- ce-curcol cs-curcol -1)))) (defun vhdl-lineup-comment (_langelem) - "Support old behavior for comment indentation. We look at -vhdl-comment-only-line-offset to decide how to indent comment -only-lines." + "Support old behavior for comment indentation. +We look at `vhdl-comment-only-line-offset' to decide how to +indent comment only-lines." (save-excursion (back-to-indentation) ;; at or to the right of comment-column @@ -7445,7 +7442,7 @@ else indent `correctly'." (setq this-command 'vhdl-electric-tab))) (defun vhdl-electric-return () - "newline-and-indent or indent-new-comment-line if in comment and preceding + "`newline-and-indent' or `indent-new-comment-line' if in comment and preceding character is a space." (interactive) (if (and (= (preceding-char) ? ) (vhdl-in-comment-p)) @@ -7456,8 +7453,8 @@ character is a space." (newline-and-indent))) (defun vhdl-indent-line () - "Indent the current line as VHDL code. Returns the amount of -indentation change." + "Indent the current line as VHDL code. +Return the amount of indentation change." (interactive) (let* ((syntax (and vhdl-indent-syntax-based (vhdl-get-syntactic-context))) (pos (- (point-max) (point))) @@ -7617,8 +7614,8 @@ ALIGN-PATTERN matches the white space to be expanded/contracted.") ;; Align code (defvar vhdl-align-try-all-clauses t - "If REGEXP is not found on the first line of the region that clause -is ignored. If this variable is non-nil, then the clause is tried anyway.") + "If REGEXP is not found on the first line of the region that clause is ignored. +If this variable is non-nil, then the clause is tried anyway.") (defun vhdl-do-group (function &optional spacing) "Apply FUNCTION on group of lines between empty lines." @@ -7637,8 +7634,7 @@ is ignored. If this variable is non-nil, then the clause is tried anyway.") (funcall function beg end spacing))) (defun vhdl-do-list (function &optional spacing) - "Apply FUNCTION to the lines of a list surrounded by a balanced group of -parentheses." + "Apply FUNCTION to lines of a list surrounded by a balanced group of parentheses." (let (beg end) (save-excursion ;; search for beginning of balanced group of parentheses @@ -7683,11 +7679,11 @@ parentheses." (funcall function beg end spacing))) (defun vhdl-align-region-1 (begin end &optional spacing alignment-list _indent) - "Attempt to align a range of lines based on the content of the -lines. The definition of `alignment-list' determines the matching -order and the manner in which the lines are aligned. If ALIGNMENT-LIST -is not specified `vhdl-align-alist' is used. If INDENT is non-nil, -indentation is done before aligning." + "Attempt to align a range of lines based on the content of the lines. +The definition of `alignment-list' determines the matching order +and the manner in which the lines are aligned. If ALIGNMENT-LIST +is not specified `vhdl-align-alist' is used. If INDENT is +non-nil, indentation is done before aligning." (interactive "r\np") (setq alignment-list (or alignment-list vhdl-align-alist)) (setq spacing (or spacing 1)) @@ -11070,7 +11066,7 @@ Point is left between them." ;; Help functions (defun vhdl-electric-space (count) - "Expand abbreviations and self-insert space(s), do indent-new-comment-line + "Expand abbreviations and self-insert space(s), do `indent-new-comment-line' if in comment and past end-comment-column." (interactive "p") (cond ((vhdl-in-comment-p) @@ -11619,8 +11615,7 @@ but not if inside a comment or quote." string))) (defun vhdl-paste-group-comment (string indent) - "Paste comment and empty lines from STRING between groups of lines -with INDENT." + "Paste comment and empty lines from STRING between groups of lines with INDENT." (let ((pos (point-marker))) (when (> indent 0) (while (string-match "^\\(--\\)" string) @@ -14919,7 +14914,8 @@ if required." (setq project-alist (cdr project-alist))))) (defun vhdl-speedbar-insert-project-hierarchy (project indent &optional rescan) - "Insert hierarchy of PROJECT. Rescan directories if RESCAN is non-nil, + "Insert hierarchy of PROJECT. +Rescan directories if optional argument RESCAN is non-nil, otherwise use cached data." (when (or rescan (and (not (assoc project vhdl-file-alist)) (not (vhdl-load-cache project)))) @@ -14937,7 +14933,8 @@ otherwise use cached data." (vhdl-speedbar-expand-units project)) (defun vhdl-speedbar-insert-dir-hierarchy (directory depth &optional rescan) - "Insert hierarchy of DIRECTORY. Rescan directory if RESCAN is non-nil, + "Insert hierarchy of DIRECTORY. +Rescan directory if optional argument RESCAN is non-nil, otherwise use cached data." (when (or rescan (and (not (assoc directory vhdl-file-alist)) (not (vhdl-load-cache directory)))) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 69cabd0b5a5..772e6646d95 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -760,7 +760,7 @@ references displayed in the current *xref* buffer." (defun xref--outdated-p (item) "Check that the match location at current position is up-to-date. -ITEMS is an xref item which " +ITEMS is an xref item which " ; FIXME: Expand documentation. ;; FIXME: The check should most likely be a generic function instead ;; of the assumption that all matches' summaries relate to the ;; buffer text in a particular way. diff --git a/lisp/rect.el b/lisp/rect.el index 504be41b673..d288adfbaf6 100644 --- a/lisp/rect.el +++ b/lisp/rect.el @@ -202,8 +202,8 @@ rectangles, as conses of the form (WIDTH . HEIGHT)." (<= (+ y2 h2) y1))))) (defun rectangle-dimensions (start end) - "Return the dimensions of the rectangle with corners at START -and END. The returned value has the form of (WIDTH . HEIGHT)." + "Return the dimensions of the rectangle with corners at START and END. +The returned value has the form of (WIDTH . HEIGHT)." (save-excursion (let* ((height (1+ (abs (- (line-number-at-pos end) (line-number-at-pos start))))) diff --git a/lisp/repeat.el b/lisp/repeat.el index 0b761fff1e3..ee9e14b5155 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -218,7 +218,7 @@ recently executed command not bound to an input event\"." ((null last-repeatable-command) (error "There is nothing to repeat")) ((eq last-repeatable-command 'mode-exit) - (error "last-repeatable-command is mode-exit & can't be repeated")) + (error "`last-repeatable-command' is `mode-exit' and can't be repeated")) ((memq last-repeatable-command repeat-too-dangerous) (error "Command %S too dangerous to repeat automatically" last-repeatable-command))) diff --git a/lisp/replace.el b/lisp/replace.el index e4155d4c27a..84ec042f455 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -63,7 +63,7 @@ it will match any sequence matched by the regexp `search-whitespace-regexp'." :version "24.3") (defvar query-replace-history nil - "Default history list for query-replace commands. + "Default history list for `query-replace' commands. See `query-replace-from-history-variable' and `query-replace-to-history-variable'.") @@ -202,7 +202,7 @@ by this function to the end of values available via (car (symbol-value query-replace-from-history-variable))))) (defun query-replace-read-from (prompt regexp-flag) - "Query and return the `from' argument of a query-replace operation. + "Query and return the `from' argument of a `query-replace' operation. Prompt with PROMPT. REGEXP-FLAG non-nil means the response should be a regexp. The return value can also be a pair (FROM . TO) indicating that the user wants to replace FROM with TO." @@ -326,8 +326,9 @@ the original string if not." (defun query-replace-read-to (from prompt regexp-flag) - "Query and return the `to' argument of a query-replace operation. -Prompt with PROMPT. REGEXP-FLAG non-nil means the response should a regexp." + "Query and return the `to' argument of a `query-replace' operation. +Prompt with PROMPT. REGEXP-FLAG non-nil means the response +should a regexp." (query-replace-compile-replacement (save-excursion (let* ((history-add-new-input nil) @@ -1300,7 +1301,7 @@ See `occur-revert-function'.") (defcustom occur-mode-find-occurrence-hook nil "Hook run by Occur after locating an occurrence. This will be called with the cursor position at the occurrence. An application -for this is to reveal context in an outline-mode when the occurrence is hidden." +for this is to reveal context in an outline mode when the occurrence is hidden." :type 'hook :group 'matching) @@ -2606,7 +2607,7 @@ passed in. If LITERAL is set, no checking is done, anyway." noedit) (defvar replace-update-post-hook nil - "Function(s) to call after query-replace has found a match in the buffer.") + "Function(s) to call after `query-replace' has found a match in the buffer.") (defvar replace-search-function nil "Function to use when searching for strings to replace. diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el index a0d4f6e96c2..84c9d06ecec 100644 --- a/lisp/ruler-mode.el +++ b/lisp/ruler-mode.el @@ -348,7 +348,7 @@ nothing is dragged.") (defun ruler-mode-text-scaled-width (width) "Compute scaled text width according to current font scaling. Convert a width of char units into a text-scaled char width units, -Ex. `window-hscroll'." +for example `window-hscroll'." (/ (* width (frame-char-width)) (default-font-width))) (defun ruler-mode-text-scaled-window-hscroll () diff --git a/lisp/server.el b/lisp/server.el index 5dd30db195a..6359a761994 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1078,7 +1078,7 @@ The following commands are accepted by the client: `-suspend' Suspend this terminal, i.e., stop the client process. - Sent when the user presses C-z." + Sent when the user presses \\[suspend-frame]." (server-log (concat "Received " string) proc) ;; First things first: let's check the authentication (unless (process-get proc :authenticated) diff --git a/lisp/ses.el b/lisp/ses.el index 9250f7ede0f..ea966295b18 100644 --- a/lisp/ses.el +++ b/lisp/ses.el @@ -299,11 +299,11 @@ Used for listing local printers or renamed cells.") ses-center-span ses-dashfill ses-dashfill-span ses-tildefill-span ses-prin1) - "List of print functions to be included in initial history of -printer functions. None of these standard-printer functions, -except function `ses-prin1', is suitable for use as a column -printer or a global-default printer because they invoke the -column or default printer and then modify its output.") + "List of print functions to be included in initial history of printer functions. +None of these standard-printer functions, except function +`ses-prin1', is suitable for use as a column printer or a +global-default printer because they invoke the column or default +printer and then modify its output.") ;;---------------------------------------------------------------------------- diff --git a/lisp/shell.el b/lisp/shell.el index 5cdc0385a6f..b575024e016 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -517,7 +517,8 @@ Shell buffers. It implements `shell-completion-execonly' for (put 'shell-mode 'mode-class 'special) (define-derived-mode shell-mode comint-mode "Shell" - "Major mode for interacting with an inferior shell.\\ + "Major mode for interacting with an inferior shell. +\\ \\[comint-send-input] after the end of the process' output sends the text from the end of process to the end of the current line. \\[comint-send-input] before end of process output copies the current line minus the prompt to diff --git a/lisp/simple.el b/lisp/simple.el index 1267c92fe54..298e3ea5ee0 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -241,7 +241,7 @@ all other buffers." (defun next-error-buffer-on-selected-frame (&optional _avoid-current extra-test-inclusive extra-test-exclusive) - "Return a single visible next-error buffer on the selected frame." + "Return a single visible `next-error' buffer on the selected frame." (let ((window-buffers (delete-dups (delq nil (mapcar (lambda (w) @@ -2133,21 +2133,23 @@ or (if one of MODES is a minor mode), if it is switched on in BUFFER." command-names))) (defcustom suggest-key-bindings t - "Non-nil means show the equivalent key-binding when M-x command has one. + "Non-nil means show the equivalent keybinding when \ +\\[execute-extended-command] has one. The value can be a length of time to show the message for. If the value is non-nil and not a number, we wait 2 seconds. Also see `extended-command-suggest-shorter'. Equivalent key-bindings are also shown in the completion list of -M-x for all commands that have them." +\\[execute-extended-command] for all commands that have them." :group 'keyboard :type '(choice (const :tag "off" nil) (integer :tag "time" 2) (other :tag "on"))) (defcustom extended-command-suggest-shorter t - "If non-nil, show a shorter M-x invocation when there is one. + "If non-nil, show a shorter \\[execute-extended-command] invocation \ +when there is one. Also see `suggest-key-bindings'." :group 'keyboard @@ -3522,7 +3524,7 @@ with < or <= based on USE-<." ;; called or in some cases on a timer called after a change is made in ;; any buffer. (defvar-local undo-auto--last-boundary-cause nil - "Describe the cause of the last undo-boundary. + "Describe the cause of the last `undo-boundary'. If `explicit', the last boundary was caused by an explicit call to `undo-boundary', that is one not called by the code in this @@ -9817,11 +9819,13 @@ warning using STRING as the message.") The argument `COMMAND' should be a symbol. -Running `M-x COMMAND RET' for the first time prompts for which +Running `\\[execute-extended-command] COMMAND RET' for \ +the first time prompts for which alternative to use and records the selected command as a custom variable. -Running `C-u M-x COMMAND RET' prompts again for an alternative +Running `\\[universal-argument] \\[execute-extended-command] COMMAND RET' \ +prompts again for an alternative and overwrites the previous choice. The variable `COMMAND-alternatives' contains an alist with diff --git a/lisp/so-long.el b/lisp/so-long.el index 65570bf253d..c975384ddb3 100644 --- a/lisp/so-long.el +++ b/lisp/so-long.el @@ -492,7 +492,7 @@ ;; considered internal-use only (with `global-so-long-mode' the interface ;; for enabling or disabling the automated behaviour). FIXME: Establish a ;; way to support the original use-case, or rename to `so-long--enabled'. - "Internal use. Non-nil when any so-long functionality has been used.") + "Internal use. Non-nil when any `so-long' functionality has been used.") (defvar-local so-long--active nil ; internal use "Non-nil when `so-long' mitigations are in effect.") @@ -1100,7 +1100,7 @@ This command calls `so-long' with the selected action as an argument.") ;;;###autoload (defun so-long-commentary () - "View the so-long library's documentation in `outline-mode'." + "View the `so-long' library's documentation in `outline-mode'." (interactive) (let ((buf "*So Long: Commentary*")) (when (buffer-live-p (get-buffer buf)) @@ -1862,14 +1862,14 @@ invoked." ;;;###autoload (defun so-long-enable () - "Enable the so-long library's functionality. + "Enable the `so-long' library's functionality. Equivalent to calling (global-so-long-mode 1)" (interactive) (global-so-long-mode 1)) (defun so-long-disable () - "Disable the so-long library's functionality. + "Disable the `so-long' library's functionality. Equivalent to calling (global-so-long-mode 0)" (interactive) diff --git a/lisp/sort.el b/lisp/sort.el index be373fba99b..d6767ed5098 100644 --- a/lisp/sort.el +++ b/lisp/sort.el @@ -507,7 +507,8 @@ Use \\[untabify] to convert tabs to spaces before sorting." (setq col-start (min col-beg1 col-end1)) (setq col-end (max col-beg1 col-end1)) (if (search-backward "\t" beg1 t) - (error "sort-columns does not work with tabs -- use M-x untabify")) + (error (substitute-command-keys + "sort-columns does not work with tabs -- use \\[untabify]"))) (if (not (or (memq system-type '(windows-nt)) (let ((pos beg1) plist fontified) (catch 'found diff --git a/lisp/subr.el b/lisp/subr.el index 0793cbca5e1..a6434bf28a8 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -22,6 +22,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: ;; declare-function's args use &rest, not &optional, for compatibility diff --git a/lisp/tempo.el b/lisp/tempo.el index 25f54af3c9d..b722cc04ca2 100644 --- a/lisp/tempo.el +++ b/lisp/tempo.el @@ -445,7 +445,7 @@ never prompted." ;;; tempo-is-user-element (defun tempo-is-user-element (element) - "Tries all the user-defined element handlers in `tempo-user-elements'." + "Try all the user-defined element handlers in `tempo-user-elements'." ;; Sigh... I need (some list) (catch 'found (mapc (lambda (handler) diff --git a/lisp/term.el b/lisp/term.el index d3d02188573..af930891043 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -340,7 +340,7 @@ (defvar term-home-marker) ; Marks the "home" position for cursor addressing. (defvar term-saved-home-marker nil "When using alternate sub-buffer, -contains saved term-home-marker from original sub-buffer.") +contains saved `term-home-marker' from original sub-buffer.") (defvar term-start-line-column 0 "(current-column) at start of screen line, or nil if unknown.") (defvar term-current-column 0 "If non-nil, is cache for (current-column).") @@ -377,7 +377,7 @@ are not allowed.") (defvar term-scroll-with-delete nil "If t, forward scrolling should be implemented by delete to top-most line(s); and if nil, scrolling should be implemented -by moving term-home-marker. It is set to t if there is a +by moving `term-home-marker'. It is set to t if there is a \(non-default) scroll-region OR the alternate buffer is used.") (defvar term-pending-delete-marker) ; New user input in line mode ; needs to be deleted, because it gets echoed by the inferior. @@ -669,7 +669,7 @@ Do not change it directly; use `term-set-escape-char' instead.") "Keymap used in Term pager mode.") (defvar term-ptyp t - "True if communications via pty; false if by pipe. Buffer local. + "Non-nil if communications via pty; false if by pipe. Buffer local. This is to work around a bug in Emacs process signaling.") (defvar term-last-input-match "" @@ -1228,8 +1228,7 @@ Entry to this mode runs the hooks on `term-mode-hook'." (process-send-string proc chars)))) (defun term-send-raw () - "Send the last character typed through the terminal-emulator -without any interpretation." + "Send last typed character to the terminal-emulator without any interpretation." (interactive) (let ((keys (this-command-keys))) (term-send-raw-string (string (aref keys (1- (length keys))))))) @@ -1401,8 +1400,8 @@ Called as a buffer-local `read-only-mode-hook' function." (force-mode-line-update)) (defun term-check-proc (buffer) - "True if there is a process associated w/buffer BUFFER, and it -is alive. BUFFER can be either a buffer or the name of one." + "Non-nil if there is a process associated w/buffer BUFFER, and it is alive. +BUFFER can be either a buffer or the name of one." (let ((proc (get-buffer-process buffer))) (and proc (memq (process-status proc) '(run stop open listen connect))))) @@ -1538,7 +1537,7 @@ Using \"emacs\" loses, because bash disables editing if $TERM == emacs.") Some other integer if Bash is new or not in use. Nil if unknown.") (defun term--bash-needs-EMACSp () - "t if Bash is old, nil if it is new or not in use." + "Return t if Bash is old, nil if it is new or not in use." (eq 43 (or term--bash-needs-EMACS-status (setf @@ -2107,17 +2106,17 @@ The values of `term-get-old-input', `term-input-filter-functions', and in the buffer. E.g., If the interpreter is the csh, - term-get-old-input is the default: take the current line, discard any - initial string matching regexp term-prompt-regexp. - term-input-filter-functions monitors input for \"cd\", \"pushd\", and + `term-get-old-input' is the default: take the current line, discard any + initial string matching regexp `term-prompt-regexp'. + `term-input-filter-functions' monitors input for \"cd\", \"pushd\", and \"popd\" commands. When it sees one, it cd's the buffer. - term-input-filter is the default: returns t if the input isn't all white + `term-input-filter' is the default: returns t if the input isn't all white space. If the term is Lucid Common Lisp, - term-get-old-input snarfs the sexp ending at point. - term-input-filter-functions does nothing. - term-input-filter returns nil if the input matches input-filter-regexp, + `term-get-old-input' snarfs the sexp ending at point. + `term-input-filter-functions' does nothing. + `term-input-filter' returns nil if the input matches input-filter-regexp, which matches (1) all whitespace (2) :a, :c, etc. Similarly for Soar, Scheme, etc." @@ -2403,8 +2402,7 @@ Useful if you accidentally suspend the top-level process." (kill-region pmark (point))))) (defun term-delchar-or-maybe-eof (arg) - "Delete ARG characters forward, or send an EOF to process if at end of -buffer." + "Delete ARG characters forward, or send an EOF to process if at end of buffer." (interactive "p") (if (eobp) (process-send-eof) @@ -3171,7 +3169,7 @@ See `term-prompt-regexp'." Set in `pre-command-hook' in char mode by `term-set-goto-process-mark'.") (defun term-set-goto-process-mark () - "Sets `term-goto-process-mark'. + "Set `term-goto-process-mark'. Always set to nil if `term-char-mode-point-at-process-mark' is nil. @@ -3430,7 +3428,7 @@ option is enabled. See `term-set-goto-process-mark'." (t))) (defun term--reset-scroll-region () - "Sets the scroll region to the full height of the terminal." + "Set the scroll region to the full height of the terminal." (term-set-scroll-region 0 (term--last-line))) (defun term-set-scroll-region (top bottom) @@ -3793,7 +3791,7 @@ all pending output has been dealt with.")) (defun term-erase-in-display (kind) "Erase (that is blank out) part of the window. -If KIND is 0, erase from (point) to (point-max); +If KIND is 0, erase from point to point-max; if KIND is 1, erase from home to point; else erase from home to point-max." (term-handle-deferred-scroll) (cond ((eq kind 0) diff --git a/lisp/textmodes/bib-mode.el b/lisp/textmodes/bib-mode.el index e2fd3ecaa42..a429aae7f70 100644 --- a/lisp/textmodes/bib-mode.el +++ b/lisp/textmodes/bib-mode.el @@ -137,7 +137,7 @@ with the cdr.") (defcustom bib-auto-capitalize t - "True to automatically capitalize appropriate fields in Bib mode." + "Non-nil to automatically capitalize appropriate fields in Bib mode." :type 'boolean) (defconst bib-capitalized-fields "%[AETCBIJR]") diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 9b3211df57a..1d450b50012 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -1861,7 +1861,7 @@ is itself incorrect, but suspiciously repeated." ;;* flyspell-highlight-duplicate-region ... */ ;;*---------------------------------------------------------------------*/ (defun flyspell-highlight-duplicate-region (beg end poss) - "Set up an overlay on a duplicate misspelled word, in the buffer from BEG to END. + "Set up overlay on duplicate misspelled word, in the buffer from BEG to END. POSS is a list of possible spelling/correction lists, as returned by `ispell-parse-output'." (let ((inhibit-read-only t)) diff --git a/lisp/textmodes/makeinfo.el b/lisp/textmodes/makeinfo.el index 13367a09bcf..6b9b3f3e9de 100644 --- a/lisp/textmodes/makeinfo.el +++ b/lisp/textmodes/makeinfo.el @@ -175,10 +175,9 @@ command to gain use of `next-error'." 'makeinfo-compilation-sentinel-region))))))) (defun makeinfo-next-error (_arg _reset) - "This function is used to disable `next-error' if the user has -used `makeinfo-region'. Since the compilation process is used on -a temporary file in that case, calling `next-error' would give -nonsensical results." + "This is used to disable `next-error' if the user has used `makeinfo-region'. +Since the compilation process is used on a temporary file in that +case, calling `next-error' would give nonsensical results." (error "Use `makeinfo-buffer' to gain use of the `next-error' command")) ;; Actually run makeinfo. COMMAND is the command to run. If diff --git a/lisp/textmodes/mhtml-mode.el b/lisp/textmodes/mhtml-mode.el index 25905385685..936732153ae 100644 --- a/lisp/textmodes/mhtml-mode.el +++ b/lisp/textmodes/mhtml-mode.el @@ -19,6 +19,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; Commentary: + ;;; Code: (eval-when-compile (require 'cl-lib)) diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el index 0a0e4cc444c..b2ebbd5f375 100644 --- a/lisp/textmodes/refill.el +++ b/lisp/textmodes/refill.el @@ -153,7 +153,7 @@ regardless of the number of after-change calls from commands doing complex processing.") (defun refill-after-change-function (_beg end _len) - "Function for `after-change-functions' which just sets `refill-doit'." + "Set `refill-doit'. Used by `after-change-functions'." (unless undo-in-progress (setq refill-doit end))) diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el index abcf119fb82..ee26d911a5d 100644 --- a/lisp/textmodes/reftex-dcr.el +++ b/lisp/textmodes/reftex-dcr.el @@ -32,14 +32,17 @@ ;;;###autoload (defun reftex-view-crossref (&optional arg auto-how fail-quietly) - "View cross reference of macro at point. Point must be on the KEY -argument. When at a `\\ref' macro, show corresponding `\\label' -definition, also in external documents (`xr'). When on a label, show -a locations where KEY is referenced. Subsequent calls find additional -locations. When on a `\\cite', show the associated `\\bibitem' macro or -the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro -which uses this KEY. When on an `\\index', show other locations marked -by the same index entry. + "View cross reference of macro at point. + +Point must be on the KEY argument. When at a `\\ref' macro, show +corresponding `\\label' definition, also in external +documents (`xr'). When on a label, show a locations where KEY is +referenced. Subsequent calls find additional locations. When on +a `\\cite', show the associated `\\bibitem' macro or the BibTeX +database entry. When on a `\\bibitem', show a `\\cite' macro +which uses this KEY. When on an `\\index', show other locations +marked by the same index entry. + To define additional cross referencing items, use the option `reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'. With one or two \\[universal-argument] prefixes, enforce rescanning of the document. diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el index 3b7518e5c3f..cc8b3244b99 100644 --- a/lisp/textmodes/reftex-global.el +++ b/lisp/textmodes/reftex-global.el @@ -338,17 +338,17 @@ Also checks if buffers visiting the files are in read-only mode." (while (setq file (pop files)) (unless (file-exists-p file) (ding) - (or (y-or-n-p (format "No such file %s. Continue? " file)) + (or (y-or-n-p (format "No such file %s. Continue?" file)) (error "Abort"))) (unless (file-writable-p file) (ding) - (or (y-or-n-p (format "No write access to %s. Continue? " file)) + (or (y-or-n-p (format "No write access to %s. Continue?" file)) (error "Abort"))) (when (and (setq buf (find-buffer-visiting file)) (with-current-buffer buf buffer-read-only)) (ding) - (or (y-or-n-p (format "Buffer %s is read-only. Continue? " + (or (y-or-n-p (format "Buffer %s is read-only. Continue?" (buffer-name buf))) (error "Abort")))))) diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el index 423c5398dd6..9d9eab4d7b5 100644 --- a/lisp/textmodes/reftex-index.el +++ b/lisp/textmodes/reftex-index.el @@ -934,8 +934,8 @@ When index is restricted, select the previous section as restriction criterion." (t nil)))) (defun reftex-index-analyze-entry (data) - ;; This splits the index context so that key, attribute and visual - ;; values are accessible individually. + "Split index context so that key, attribute and visual +values are accessible individually." (interactive) (let* ((arg (nth 5 data)) (context (nth 2 data)) diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index 9def10cee05..c521a07f192 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el @@ -435,7 +435,8 @@ This function also makes sure the old toc markers do not point anywhere." ;;;###autoload (defun reftex-section-info (file) "Return a section entry for the current match. -Careful: This function expects the match-data to be still in place!" +Careful: This function expects the `match-data' to still be in +place!" (let* ((marker (set-marker (make-marker) (1- (match-beginning 3)))) (macro (reftex-match-string 3)) (prefix (save-match-data @@ -494,7 +495,8 @@ will rescan the entire document." ;;;###autoload (defun reftex-index-info (file) "Return an index entry for the current match. -Careful: This function expects the match-data to be still in place!" +Careful: This function expects the `match-data' to still be in +place!" (catch 'exit (let* ((macro (reftex-match-string 10)) (bom (match-beginning 10)) diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el index 23f2193501d..d57a7678553 100644 --- a/lisp/textmodes/reftex-vars.el +++ b/lisp/textmodes/reftex-vars.el @@ -330,7 +330,8 @@ select the nearest entry with the correct new level." "The maximum level of toc entries which will be included in the TOC. Section headings with a bigger level will be ignored. In RefTeX, chapters are level 1, sections are level 2 etc. -This variable can be changed from within the *toc* buffer with the `t' key." +This variable can be changed from within the *toc* buffer with \ +\\\\[reftex-toc-max-level]." :group 'reftex-table-of-contents-browser :type 'integer) @@ -1208,7 +1209,7 @@ path." :type '(repeat (file))) (defcustom reftex-sort-bibtex-matches 'reverse-year - "Sorting of the entries found in BibTeX databases by reftex-citation. + "Sorting of the entries found in BibTeX databases by `reftex-citation'. Possible values: nil Do not sort entries. `author' Sort entries by author name. @@ -1364,7 +1365,7 @@ should return the string to insert into the buffer." :type '(choice (const nil) function)) (defcustom reftex-select-bib-mode-hook nil - "Mode hook for reftex-select-bib-mode." + "Mode hook for `reftex-select-bib-mode'." :group 'reftex-citation-support :type 'hook) @@ -1840,7 +1841,7 @@ upon the variable `reftex-initialize-temporary-buffers'." (defcustom reftex-initialize-temporary-buffers nil "Non-nil means do initializations even when visiting file temporarily. -When nil, RefTeX may turn off find-file hooks and other stuff to briefly +When nil, RefTeX may turn off `find-file' hooks and other stuff to briefly visit a file. When t, the full default initializations are done (find-file-hook etc.). Instead of t or nil, this variable may also be a list of hook functions to diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el index 604a67df323..550994cd7b6 100644 --- a/lisp/textmodes/texinfmt.el +++ b/lisp/textmodes/texinfmt.el @@ -932,9 +932,9 @@ commands." "Text of the copyright notice and copying permissions.") (defun texinfo-copying () - "Copy the copyright notice and copying permissions from the Texinfo file, -as indicated by the @copying ... @end copying command; -insert the text with the @insertcopying command." + "Copy the copyright notice and copying permissions from Texinfo file. +This is indicated by the \"@copying ... @end copying\" command; +insert the text with the \"@insertcopying\" command." (let ((beg (progn (beginning-of-line) (point))) (end (progn (re-search-forward "^@end copying[ \t]*\n") (point)))) (setq texinfo-copying-text @@ -944,8 +944,8 @@ insert the text with the @insertcopying command." (delete-region beg end))) (defun texinfo-insertcopying () - "Insert the copyright notice and copying permissions from the Texinfo file, -which are indicated by the @copying ... @end copying command." + "Insert the copyright notice and copying permissions from Texinfo file. +This is indicated by the \"@copying ... @end copying\" command." (insert (concat "\n" texinfo-copying-text))) (put 'begin 'texinfo-format 'texinfo-format-begin) @@ -2546,7 +2546,9 @@ If used within a line, follow `@bullet' with braces." "smalllisp" "\\)") "Regexp specifying end of environments in which @kbd does not put `...' -around argument. (See `texinfo-format-kbd-regexp')") +around argument. + +See `texinfo-format-kbd-regexp'.") (put 'kbd 'texinfo-format 'texinfo-format-kbd) (defun texinfo-format-kbd () diff --git a/lisp/transient.el b/lisp/transient.el index 2be82f56d86..f3d3902a77e 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1289,8 +1289,8 @@ variable instead.") (defvar transient--exitp nil "Whether to exit the transient.") (defvar transient--showp nil "Whether the transient is show in a popup buffer.") -(defvar transient--helpp nil "Whether help-mode is active.") -(defvar transient--editp nil "Whether edit-mode is active.") +(defvar transient--helpp nil "Whether `help-mode' is active.") +(defvar transient--editp nil "Whether `edit-mode' is active.") (defvar transient--active-infix nil "The active infix awaiting user input.") diff --git a/lisp/wdired.el b/lisp/wdired.el index eafb50cc18a..eb5a6385563 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -453,7 +453,7 @@ non-nil means return old filename." (remove-function (local 'revert-buffer-function) #'wdired-revert)) (defun wdired-abort-changes () - "Abort changes and return to dired mode." + "Abort changes and return to `dired-mode'." (interactive) (remove-hook 'before-change-functions #'wdired--before-change-fn t) (let ((inhibit-read-only t)) @@ -689,7 +689,7 @@ Optional arguments are ignored." ;; FIXME: Can't we use the normal mechanism for that? --Stef (if (and (buffer-modified-p) - (not (y-or-n-p "Buffer changed. Discard changes and kill buffer?"))) + (not (y-or-n-p "Buffer changed. Discard changes and kill buffer?"))) (error "Error"))) ;; Added to after-change-functions in wdired-change-to-wdired-mode to diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 59d3249c5de..e193be6cdd2 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -565,8 +565,8 @@ Used when `whitespace-style' includes the value `space-before-tab'.") (defvar whitespace-indentation 'whitespace-indentation - "Symbol face used to visualize `tab-width' or more SPACEs at beginning of -line. Used when `whitespace-style' includes the value `indentation'.") + "Symbol face used to visualize `tab-width' or more SPACEs at beginning of line. +Used when `whitespace-style' includes the value `indentation'.") (make-obsolete-variable 'whitespace-indentation "use the face instead." "24.4") (defface whitespace-indentation @@ -2353,7 +2353,7 @@ Also refontify when necessary." (defun whitespace-display-vector-p (vec) - "Return true if every character in vector VEC can be displayed." + "Return non-nil if every character in vector VEC can be displayed." (let ((i (length vec))) (when (> i 0) (while (and (>= (setq i (1- i)) 0) diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 9a34dc8d438..ab358da7e3f 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -190,7 +190,7 @@ the contents of strings." (buffer-enable-undo)) (defcustom widget-menu-max-size 40 - "Largest number of items allowed in a popup-menu. + "Largest number of items allowed in a popup menu. Larger menus are read through the minibuffer." :group 'widgets :type 'integer) @@ -202,9 +202,8 @@ For a larger number of items, the minibuffer is used." :type 'integer) (defcustom widget-menu-minibuffer-flag nil - "Control how to ask for a choice from the keyboard. -Non-nil means use the minibuffer; -nil means read a single character." + "Non-nil means use the minibuffer; to ask for a choice from the keyboard. +If nil, read a single character." :group 'widgets :type 'boolean) diff --git a/lisp/woman.el b/lisp/woman.el index fe9f8969c3e..1ca4d5e8716 100644 --- a/lisp/woman.el +++ b/lisp/woman.el @@ -1790,7 +1790,7 @@ Argument EVENT is the invoking mouse event." ;; That comment was moved after the symbol `woman-menu' to make ;; find-function-search-for-symbol work. -- rost woman-mode-map - "WoMan Menu" + "WoMan Menu." `("WoMan" ["WoMan..." woman t] ; [NAME CALLBACK ENABLE] "--" @@ -2182,7 +2182,7 @@ To be called on original buffer and any .so insertions." ;; variable. zsoelim is always run as the very first preprocessor. (defvar woman-emulate-tbl nil - "True if WoMan should emulate the tbl preprocessor. + "Non-nil if WoMan should emulate the tbl preprocessor. This applies to text between .TE and .TS directives. Currently set only from \\='\\\" t in the first line of the source file.") -- cgit v1.2.3 From 5d96fad27863497a427c80550070e435a4c9e0d9 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 23 Sep 2021 19:32:36 +0300 Subject: New thing-at-point target 'list-or-string' used in context-menu-region * lisp/mouse.el (context-menu-region): Rearrange the order to All>Defun>List>Line>Symbol. Show title either "List" or "String" depending on syntax-ppss, then use thing 'list-or-string' (bug#9054). * lisp/thingatpt.el (thing-at-point-bounds-of-list-at-point): Add optional args 'escape-strings' and 'no-syntax-crossing' like in 'up-list'. (list-or-string): New target 'list-or-string'. (thing-at-point-bounds-of-list-or-string-at-point): New function. --- etc/NEWS | 3 +++ lisp/mouse.el | 24 +++++++++++++----------- lisp/thingatpt.el | 13 +++++++++++-- 3 files changed, 27 insertions(+), 13 deletions(-) (limited to 'lisp/mouse.el') diff --git a/etc/NEWS b/etc/NEWS index 175bae09e8e..e9b60e95945 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2586,6 +2586,9 @@ This new command (bound to 'C-c C-l') regenerates the current hunk. This is like 'filename', but is a full path, and is nil if the file doesn't exist. +*** New 'thing-at-point' target: 'list-or-string'. +This is like 'list', but also prefers to find of any enclosing string. + +++ *** New variable 'thing-at-point-provider-alist'. This allows mode-specific alterations to how 'thing-at-point' works. diff --git a/lisp/mouse.el b/lisp/mouse.el index 41333eb7f71..382c101159b 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -455,10 +455,11 @@ Some context functions add menu items below the separator." `(menu-item "Paste" mouse-yank-at-click :help "Paste (yank) text most recently cut/copied"))) (when (and (cdr yank-menu) (not buffer-read-only)) - (let ((submenu (make-sparse-keymap (propertize "Paste from Kill Menu")))) - (dolist (item yank-menu) + (let ((submenu (make-sparse-keymap (propertize "Paste from Kill Menu"))) + (i 0)) + (dolist (item (reverse yank-menu)) (when (consp item) - (define-key-after submenu (vector (car item)) + (define-key submenu (vector (setq i (1+ i))) `(menu-item ,(cadr item) ,(lambda () (interactive) (mouse-yank-from-menu click (car item))))))) @@ -477,18 +478,19 @@ Some context functions add menu items below the separator." `(menu-item "All" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'buffer)) :help "Mark the whole buffer for a subsequent cut/copy")) - (define-key-after submenu [mark-line] - `(menu-item "Line" - ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line)) - :help "Mark the line at click for a subsequent cut/copy")) (define-key-after submenu [mark-defun] `(menu-item "Defun" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'defun)) :help "Mark the defun at click for a subsequent cut/copy")) - (define-key-after submenu [mark-list] - `(menu-item "List" - ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list)) - :help "Mark the list at click for a subsequent cut/copy")) + (define-key-after submenu [mark-list-or-string] + `(menu-item ,(if (nth 8 (syntax-ppss (posn-point (event-end click)))) + "String" "List") + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list-or-string)) + :help "Mark list or string at click for a subsequent cut/copy")) + (define-key-after submenu [mark-line] + `(menu-item "Line" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line)) + :help "Mark the line at click for a subsequent cut/copy")) (define-key-after submenu [mark-symbol] `(menu-item "Symbol" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'symbol)) diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 58ef2cfd917..09a86d22438 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -284,18 +284,27 @@ The bounds of THING are determined by `bounds-of-thing-at-point'." (put 'list 'bounds-of-thing-at-point 'thing-at-point-bounds-of-list-at-point) -(defun thing-at-point-bounds-of-list-at-point () +(defun thing-at-point-bounds-of-list-at-point (&optional escape-strings no-syntax-crossing) "Return the bounds of the list at point. Prefer the enclosing list with fallback on sexp at point. \[Internal function used by `bounds-of-thing-at-point'.]" (save-excursion - (if (ignore-errors (up-list -1)) + (if (ignore-errors (up-list -1 escape-strings no-syntax-crossing)) (ignore-errors (cons (point) (progn (forward-sexp) (point)))) (let ((bound (bounds-of-thing-at-point 'sexp))) (and bound (<= (car bound) (point)) (< (point) (cdr bound)) bound))))) +(put 'list-or-string 'bounds-of-thing-at-point + 'thing-at-point-bounds-of-list-or-string-at-point) + +(defun thing-at-point-bounds-of-list-or-string-at-point () + "Return the bounds of the list or string at point. +Like `thing-at-point-bounds-of-list-at-point', but also +prefer to find of any enclosing string." + (thing-at-point-bounds-of-list-at-point t t)) + ;; Defuns (put 'defun 'beginning-op 'beginning-of-defun) -- cgit v1.2.3 From 13d930deddd2e0529a0fb0f2fb93dd621d6d35be Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 23 Sep 2021 19:52:49 +0300 Subject: * lisp/mouse.el (context-menu-region): Use save-excursion for syntax-ppss. --- lisp/mouse.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 382c101159b..8ad3f7664a2 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -483,7 +483,8 @@ Some context functions add menu items below the separator." ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'defun)) :help "Mark the defun at click for a subsequent cut/copy")) (define-key-after submenu [mark-list-or-string] - `(menu-item ,(if (nth 8 (syntax-ppss (posn-point (event-end click)))) + `(menu-item ,(if (nth 8 (save-excursion + (syntax-ppss (posn-point (event-end click))))) "String" "List") ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list-or-string)) :help "Mark list or string at click for a subsequent cut/copy")) -- cgit v1.2.3 From 2abf143f8185fced544c4f8d144ea710142d7a59 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 24 Sep 2021 09:29:52 +0300 Subject: New thing-at-point target 'string' used in context-menu-region * lisp/mouse.el (context-menu-region): Use separate "List" and "String". * lisp/thingatpt.el (string): New target 'string'. (thing-at-point-bounds-of-string-at-point): New function. (thing-at-point-bounds-of-list-at-point): Revert previous commit by removing optional args 'escape-strings' and 'no-syntax-crossing'. (list-or-string): Remove recently added target 'list-or-string'. (thing-at-point-bounds-of-list-or-string-at-point): Remove function. https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg01737.html --- etc/NEWS | 7 ++----- lisp/mouse.el | 17 +++++++++++------ lisp/thingatpt.el | 39 +++++++++++++++++++++++++-------------- 3 files changed, 38 insertions(+), 25 deletions(-) (limited to 'lisp/mouse.el') diff --git a/etc/NEWS b/etc/NEWS index b0e2d2c060e..02cbaa51ed3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2593,11 +2593,8 @@ This new command (bound to 'C-c C-l') regenerates the current hunk. This is like 'filename', but is a full path, and is nil if the file doesn't exist. -*** New 'thing-at-point' target: 'list-or-string'. -This is like 'list, but if point is inside a string that's enclosed in -the list, it returns the enclosed string and not the enclosing list. - -This is like 'list', but also prefers to find of any enclosing string. +*** New 'thing-at-point' target: 'string'. +If point is inside a string, it returns the enclosed string. +++ *** New variable 'thing-at-point-provider-alist'. diff --git a/lisp/mouse.el b/lisp/mouse.el index 8ad3f7664a2..9f1417f420d 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -482,12 +482,17 @@ Some context functions add menu items below the separator." `(menu-item "Defun" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'defun)) :help "Mark the defun at click for a subsequent cut/copy")) - (define-key-after submenu [mark-list-or-string] - `(menu-item ,(if (nth 8 (save-excursion - (syntax-ppss (posn-point (event-end click))))) - "String" "List") - ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list-or-string)) - :help "Mark list or string at click for a subsequent cut/copy")) + (define-key-after submenu [mark-list] + `(menu-item "List" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list)) + :help "Mark the list at click for a subsequent cut/copy")) + (when (let ((pos (posn-point (event-end click)))) + (or (eq (char-syntax (char-after pos)) ?\") + (nth 3 (save-excursion (syntax-ppss pos))))) + (define-key-after submenu [mark-string] + `(menu-item "String" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'string)) + :help "Mark the string at click for a subsequent cut/copy"))) (define-key-after submenu [mark-line] `(menu-item "Line" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line)) diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index efe33982c3c..32e66184d70 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -231,7 +231,27 @@ The bounds of THING are determined by `bounds-of-thing-at-point'." (put 'line 'beginning-op (lambda () (if (bolp) (forward-line -1) (beginning-of-line)))) -;; Sexps +;; Strings + +(put 'string 'bounds-of-thing-at-point 'thing-at-point-bounds-of-string-at-point) + +(defun thing-at-point-bounds-of-string-at-point () + "Return the bounds of the string at point. +Prefer the enclosing string with fallback on sexp at point. +\[Internal function used by `bounds-of-thing-at-point'.]" + (save-excursion + (let ((ppss (syntax-ppss))) + (if (nth 3 ppss) + ;; Inside the string + (ignore-errors + (goto-char (nth 8 ppss)) + (cons (point) (progn (forward-sexp) (point)))) + ;; At the beginning of the string + (if (eq (char-syntax (char-after)) ?\") + (let ((bound (bounds-of-thing-at-point 'sexp))) + (and bound + (<= (car bound) (point)) (< (point) (cdr bound)) + bound))))))) (defun in-string-p () "Return non-nil if point is in a string." @@ -241,6 +261,8 @@ The bounds of THING are determined by `bounds-of-thing-at-point'." (beginning-of-defun) (nth 3 (parse-partial-sexp (point) orig))))) +;; Sexps + (defun thing-at-point--end-of-sexp () "Move point to the end of the current sexp." (let ((char-syntax (syntax-after (point)))) @@ -284,29 +306,18 @@ The bounds of THING are determined by `bounds-of-thing-at-point'." (put 'list 'bounds-of-thing-at-point 'thing-at-point-bounds-of-list-at-point) -(defun thing-at-point-bounds-of-list-at-point (&optional escape-strings no-syntax-crossing) +(defun thing-at-point-bounds-of-list-at-point () "Return the bounds of the list at point. Prefer the enclosing list with fallback on sexp at point. \[Internal function used by `bounds-of-thing-at-point'.]" (save-excursion - (if (ignore-errors (up-list -1 escape-strings no-syntax-crossing)) + (if (ignore-errors (up-list -1)) (ignore-errors (cons (point) (progn (forward-sexp) (point)))) (let ((bound (bounds-of-thing-at-point 'sexp))) (and bound (<= (car bound) (point)) (< (point) (cdr bound)) bound))))) -(put 'list-or-string 'bounds-of-thing-at-point - 'thing-at-point-bounds-of-list-or-string-at-point) - -(defun thing-at-point-bounds-of-list-or-string-at-point () - "Return the bounds of the list or string at point. -Like `thing-at-point-bounds-of-list-at-point', but if -point is inside a string that's enclosed in the list, this -function will return the enclosed string and not the -enclosing list." - (thing-at-point-bounds-of-list-at-point t t)) - ;; Defuns (put 'defun 'beginning-op 'beginning-of-defun) -- cgit v1.2.3 From 28f8ffa58ee6c3af5e486dd5cb28e7dbf680232f Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 27 Sep 2021 18:41:34 +0300 Subject: * lisp/mouse.el (context-menu-region): Check for nil for char-after at eobp. --- lisp/mouse.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 9f1417f420d..d80b241af52 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -486,8 +486,9 @@ Some context functions add menu items below the separator." `(menu-item "List" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list)) :help "Mark the list at click for a subsequent cut/copy")) - (when (let ((pos (posn-point (event-end click)))) - (or (eq (char-syntax (char-after pos)) ?\") + (when (let* ((pos (posn-point (event-end click))) + (char (when pos (char-after pos)))) + (or (and char (eq (char-syntax char) ?\")) (nth 3 (save-excursion (syntax-ppss pos))))) (define-key-after submenu [mark-string] `(menu-item "String" -- cgit v1.2.3 From 2d1564103e2024eeb4377b473f28e1523a5206bc Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 28 Sep 2021 22:00:41 +0300 Subject: * lisp/mouse.el (context-menu-map): Fix when menu is a command (bug#50851) * lisp/help.el (help--analyze-key): Get information at the position of mouse click such as 'C-h k' on a context menu item (bug#50067). --- lisp/help.el | 2 +- lisp/mouse.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/help.el b/lisp/help.el index 8f771670408..b794751ecab 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -695,7 +695,7 @@ Returns a list of the form (BRIEF-DESC DEFN EVENT MOUSE-MSG)." (mouse-msg (if (or (memq 'click modifiers) (memq 'down modifiers) (memq 'drag modifiers)) " at that spot" "")) - (defn (key-binding key t))) + (defn (save-excursion (mouse-set-point event) (key-binding key t)))) ;; Handle the case where we faked an entry in "Select and Paste" menu. (when (and (eq defn nil) (stringp (aref key (1- (length key)))) diff --git a/lisp/mouse.el b/lisp/mouse.el index d80b241af52..5d4e05fa25e 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -328,7 +328,7 @@ the function `context-menu-filter-function'." ;; Remove duplicate separators (let ((l menu)) - (while l + (while (consp l) (when (and (equal (cdr-safe (car l)) menu-bar-separator) (equal (cdr-safe (cadr l)) menu-bar-separator)) (setcdr l (cddr l))) -- cgit v1.2.3 From 121a5abeaee85e7955786d838f07103ce074a63b Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 3 Oct 2021 20:35:49 +0300 Subject: Move context-menu selection items Defun/List/Symbol to prog-mode (bug#9054) * lisp/mouse.el (context-menu-functions): Add context-menu-middle-separator to choices. (context-menu-region): Move Defun/List/Symbol selection items to prog-context-menu. * lisp/progmodes/prog-mode.el (prog-context-menu): Move Defun/List/Symbol selection items from context-menu-region. Include text-mode select menu only in strings and comments. * lisp/textmodes/text-mode.el (text-mode-menu): New function. (text-mode): Add text-mode-menu to context-menu-functions. --- lisp/mouse.el | 13 +------------ lisp/progmodes/prog-mode.el | 22 ++++++++++++++++++++++ lisp/textmodes/text-mode.el | 25 ++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 13 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 5d4e05fa25e..bb47d04a3a8 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -290,6 +290,7 @@ and should return the same menu with changes such as added new menu items." :type '(repeat (choice (function-item context-menu-undo) (function-item context-menu-region) + (function-item context-menu-middle-separator) (function-item context-menu-toolbar) (function-item context-menu-global) (function-item context-menu-local) @@ -478,14 +479,6 @@ Some context functions add menu items below the separator." `(menu-item "All" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'buffer)) :help "Mark the whole buffer for a subsequent cut/copy")) - (define-key-after submenu [mark-defun] - `(menu-item "Defun" - ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'defun)) - :help "Mark the defun at click for a subsequent cut/copy")) - (define-key-after submenu [mark-list] - `(menu-item "List" - ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list)) - :help "Mark the list at click for a subsequent cut/copy")) (when (let* ((pos (posn-point (event-end click))) (char (when pos (char-after pos)))) (or (and char (eq (char-syntax char) ?\")) @@ -498,10 +491,6 @@ Some context functions add menu items below the separator." `(menu-item "Line" ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line)) :help "Mark the line at click for a subsequent cut/copy")) - (define-key-after submenu [mark-symbol] - `(menu-item "Symbol" - ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'symbol)) - :help "Mark the symbol at click for a subsequent cut/copy")) (when (region-active-p) (define-key-after submenu [mark-none] `(menu-item "None" diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 6c09dcf881d..4f15686dc87 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -68,6 +68,28 @@ `(menu-item "Find Definition" xref-find-definitions-at-mouse :help ,(format "Find definition of `%s'" identifier)) 'prog-separator))) + + (when (thing-at-mouse click 'symbol) + (define-key-after menu [select-region mark-symbol] + `(menu-item "Symbol" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'symbol)) + :help "Mark the symbol at click for a subsequent cut/copy") + 'mark-whole-buffer)) + (define-key-after menu [select-region mark-list] + `(menu-item "List" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list)) + :help "Mark the list at click for a subsequent cut/copy") + 'mark-whole-buffer) + (define-key-after menu [select-region mark-defun] + `(menu-item "Defun" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'defun)) + :help "Mark the defun at click for a subsequent cut/copy") + 'mark-whole-buffer) + + ;; Include text-mode select menu only in strings and comments. + (when (nth 8 (save-excursion (syntax-ppss (posn-point (event-end click))))) + (text-mode-menu menu click)) + menu) (defvar prog-mode-map diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el index 74c6d412a65..3243bd31c4c 100644 --- a/lisp/textmodes/text-mode.el +++ b/lisp/textmodes/text-mode.el @@ -95,6 +95,28 @@ inherit all the commands defined in this map.") :style toggle :selected (memq 'turn-on-auto-fill text-mode-hook)])) +(defun text-mode-menu (menu click) + "Populate MENU with text selection commands at CLICK." + + (when (thing-at-mouse click 'word) + (define-key-after menu [select-region mark-word] + `(menu-item "Word" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'word)) + :help "Mark the word at click for a subsequent cut/copy") + 'mark-whole-buffer)) + (define-key-after menu [select-region mark-sentence] + `(menu-item "Sentence" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'sentence)) + :help "Mark the sentence at click for a subsequent cut/copy") + 'mark-whole-buffer) + (define-key-after menu [select-region mark-paragraph] + `(menu-item "Paragraph" + ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'paragraph)) + :help "Mark the paragraph at click for a subsequent cut/copy") + 'mark-whole-buffer) + + menu) + (define-derived-mode text-mode nil "Text" "Major mode for editing text written for humans to read. @@ -104,7 +126,8 @@ You can thus get the full benefit of adaptive filling \\{text-mode-map} Turning on Text mode runs the normal hook `text-mode-hook'." (setq-local text-mode-variant t) - (setq-local require-final-newline mode-require-final-newline)) + (setq-local require-final-newline mode-require-final-newline) + (add-hook 'context-menu-functions 'text-mode-menu 10 t)) (define-derived-mode paragraph-indent-text-mode text-mode "Parindent" "Major mode for editing text, with leading spaces starting a paragraph. -- cgit v1.2.3 From e62d1fa9831cc4f046b330f438f8bd49a27a2458 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 6 Oct 2021 10:42:56 +0200 Subject: Improve interaction between mouse-drag-region and scroll-margin * lisp/mouse.el (mouse-drag-track): Disable both scroll-margin and auto-hscroll-mode in mouse-drag-region and do not re-enable them until dragging is over, making selections work as expected when inside the margins. --- lisp/mouse.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index bb47d04a3a8..3c457a36c55 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -1568,8 +1568,7 @@ The region will be defined with mark and point." (mouse-minibuffer-check start-event) (setq mouse-selection-click-count-buffer (current-buffer)) (deactivate-mark) - (let* ((scroll-margin 0) ; Avoid margin scrolling (Bug#9541). - (start-posn (event-start start-event)) + (let* ((start-posn (event-start start-event)) (start-point (posn-point start-posn)) (start-window (posn-window start-posn)) (_ (with-current-buffer (window-buffer start-window) @@ -1591,12 +1590,20 @@ The region will be defined with mark and point." ;; Don't count the mode line. (1- (nth 3 bounds)))) (click-count (1- (event-click-count start-event))) - ;; Suppress automatic hscrolling, because that is a nuisance - ;; when setting point near the right fringe (but see below). + ;; Save original automatic scrolling behavior (see below). (auto-hscroll-mode-saved auto-hscroll-mode) + (scroll-margin-saved scroll-margin) (old-track-mouse track-mouse)) (setq mouse-selection-click-count click-count) + + ;; Suppress automatic scrolling near the edges while tracking + ;; movement, as it interferes with the natural dragging behavior + ;; (point will unexpectedly be moved beneath the pointer, making + ;; selections in auto-scrolling margins impossible). + (setq auto-hscroll-mode nil) + (setq scroll-margin 0) + ;; In case the down click is in the middle of some intangible text, ;; use the end of that text, and put it in START-POINT. (if (< (point) start-point) @@ -1615,7 +1622,6 @@ The region will be defined with mark and point." (setf (terminal-parameter nil 'mouse-drag-start) start-event) (setq track-mouse t) - (setq auto-hscroll-mode nil) (set-transient-map (let ((map (make-sparse-keymap))) @@ -1626,8 +1632,6 @@ The region will be defined with mark and point." (let* ((end (event-end event)) (end-point (posn-point end))) (unless (eq end-point start-point) - ;; As soon as the user moves, we can re-enable auto-hscroll. - (setq auto-hscroll-mode auto-hscroll-mode-saved) ;; And remember that we have moved, so mouse-set-region can know ;; its event is really a drag event. (setcar start-event 'mouse-movement)) @@ -1648,6 +1652,7 @@ The region will be defined with mark and point." t (lambda () (setq track-mouse old-track-mouse) (setq auto-hscroll-mode auto-hscroll-mode-saved) + (setq scroll-margin scroll-margin-saved) ;; Don't deactivate the mark when the context menu was invoked ;; by down-mouse-3 immediately after down-mouse-1 and without ;; releasing the mouse button with mouse-1. This allows to use -- cgit v1.2.3 From dc5bb729589ce10734a1a03536026ded8745eba0 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 6 Oct 2021 10:43:22 +0200 Subject: Perform cleanup on errors in mouse-drag-track * lisp/mouse.el (mouse-drag-track): Disable both scroll-margin and auto-hscroll-mode in mouse-drag-region and do not re-enable them until dragging is over, making selections work as expected when inside the margins. * lisp/mouse.el (mouse-drag-track): Correctly reset original values changed during execution if errors occur. --- lisp/mouse.el | 140 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 67 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 3c457a36c55..1cbdaaf8129 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -1593,75 +1593,81 @@ The region will be defined with mark and point." ;; Save original automatic scrolling behavior (see below). (auto-hscroll-mode-saved auto-hscroll-mode) (scroll-margin-saved scroll-margin) - (old-track-mouse track-mouse)) - - (setq mouse-selection-click-count click-count) - - ;; Suppress automatic scrolling near the edges while tracking - ;; movement, as it interferes with the natural dragging behavior - ;; (point will unexpectedly be moved beneath the pointer, making - ;; selections in auto-scrolling margins impossible). - (setq auto-hscroll-mode nil) - (setq scroll-margin 0) + (old-track-mouse track-mouse) + (cleanup (lambda () + (setq track-mouse old-track-mouse) + (setq auto-hscroll-mode auto-hscroll-mode-saved) + (setq scroll-margin scroll-margin-saved)))) + (condition-case err + (progn + (setq mouse-selection-click-count click-count) + + ;; Suppress automatic scrolling near the edges while tracking + ;; movement, as it interferes with the natural dragging behavior + ;; (point will unexpectedly be moved beneath the pointer, making + ;; selections in auto-scrolling margins impossible). + (setq auto-hscroll-mode nil) + (setq scroll-margin 0) + + ;; In case the down click is in the middle of some intangible text, + ;; use the end of that text, and put it in START-POINT. + (if (< (point) start-point) + (goto-char start-point)) + (setq start-point (point)) + + ;; Activate the region, using `mouse-start-end' to determine where + ;; to put point and mark (e.g., double-click will select a word). + (setq-local transient-mark-mode + (if (eq transient-mark-mode 'lambda) + '(only) + (cons 'only transient-mark-mode))) + (let ((range (mouse-start-end start-point start-point click-count))) + (push-mark (nth 0 range) t t) + (goto-char (nth 1 range))) - ;; In case the down click is in the middle of some intangible text, - ;; use the end of that text, and put it in START-POINT. - (if (< (point) start-point) - (goto-char start-point)) - (setq start-point (point)) + (setf (terminal-parameter nil 'mouse-drag-start) start-event) + (setq track-mouse t) - ;; Activate the region, using `mouse-start-end' to determine where - ;; to put point and mark (e.g., double-click will select a word). - (setq-local transient-mark-mode - (if (eq transient-mark-mode 'lambda) - '(only) - (cons 'only transient-mark-mode))) - (let ((range (mouse-start-end start-point start-point click-count))) - (push-mark (nth 0 range) t t) - (goto-char (nth 1 range))) - - (setf (terminal-parameter nil 'mouse-drag-start) start-event) - (setq track-mouse t) - - (set-transient-map - (let ((map (make-sparse-keymap))) - (define-key map [switch-frame] #'ignore) - (define-key map [select-window] #'ignore) - (define-key map [mouse-movement] - (lambda (event) (interactive "e") - (let* ((end (event-end event)) - (end-point (posn-point end))) - (unless (eq end-point start-point) - ;; And remember that we have moved, so mouse-set-region can know - ;; its event is really a drag event. - (setcar start-event 'mouse-movement)) - (if (and (eq (posn-window end) start-window) - (integer-or-marker-p end-point)) - (mouse--drag-set-mark-and-point start-point - end-point click-count) - (let ((mouse-row (cdr (cdr (mouse-position))))) - (cond - ((null mouse-row)) - ((< mouse-row top) - (mouse-scroll-subr start-window (- mouse-row top) - nil start-point)) - ((>= mouse-row bottom) - (mouse-scroll-subr start-window (1+ (- mouse-row bottom)) - nil start-point)))))))) - map) - t (lambda () - (setq track-mouse old-track-mouse) - (setq auto-hscroll-mode auto-hscroll-mode-saved) - (setq scroll-margin scroll-margin-saved) - ;; Don't deactivate the mark when the context menu was invoked - ;; by down-mouse-3 immediately after down-mouse-1 and without - ;; releasing the mouse button with mouse-1. This allows to use - ;; region-related context menu to operate on the selected region. - (unless (and context-menu-mode - (eq (car-safe (aref (this-command-keys-vector) 0)) - 'down-mouse-3)) - (deactivate-mark) - (pop-mark)))))) + (set-transient-map + (let ((map (make-sparse-keymap))) + (define-key map [switch-frame] #'ignore) + (define-key map [select-window] #'ignore) + (define-key map [mouse-movement] + (lambda (event) (interactive "e") + (let* ((end (event-end event)) + (end-point (posn-point end))) + (unless (eq end-point start-point) + ;; And remember that we have moved, so mouse-set-region can know + ;; its event is really a drag event. + (setcar start-event 'mouse-movement)) + (if (and (eq (posn-window end) start-window) + (integer-or-marker-p end-point)) + (mouse--drag-set-mark-and-point start-point + end-point click-count) + (let ((mouse-row (cdr (cdr (mouse-position))))) + (cond + ((null mouse-row)) + ((< mouse-row top) + (mouse-scroll-subr start-window (- mouse-row top) + nil start-point)) + ((>= mouse-row bottom) + (mouse-scroll-subr start-window (1+ (- mouse-row bottom)) + nil start-point)))))))) + map) + t (lambda () + (funcall cleanup) + ;; Don't deactivate the mark when the context menu was invoked + ;; by down-mouse-3 immediately after down-mouse-1 and without + ;; releasing the mouse button with mouse-1. This allows to use + ;; region-related context menu to operate on the selected region. + (unless (and context-menu-mode + (eq (car-safe (aref (this-command-keys-vector) 0)) + 'down-mouse-3)) + (deactivate-mark) + (pop-mark))))) + ;; Cleanup on errors + (error (funcall cleanup) + (signal (car err) (cdr err)))))) (defun mouse--drag-set-mark-and-point (start click click-count) (let* ((range (mouse-start-end start click click-count)) -- cgit v1.2.3 From b9b78b263148d26ea585622e98e8e5ccd2602799 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 14 Oct 2021 12:29:43 +0300 Subject: Fix Help functions for clicks on tool bar and tab bar * lisp/mouse.el (mouse-minibuffer-check): Don't assume posn-window returns a window. (Bug#5199) --- lisp/mouse.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index bb47d04a3a8..bcb58d153a8 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -571,7 +571,8 @@ This is the keyboard interface to \\[context-menu-map]." (defun mouse-minibuffer-check (event) (let ((w (posn-window (event-start event)))) - (and (window-minibuffer-p w) + (and (windowp w) + (window-minibuffer-p w) (not (minibuffer-window-active-p w)) (user-error "Minibuffer window is not active"))) ;; Give temporary modes such as isearch a chance to turn off. -- cgit v1.2.3 From 1cdb4d2077c4e402bf2b2991e8395f0ccdedd1d1 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 21 Oct 2021 19:55:24 +0300 Subject: * lisp/menu-bar.el (menu-bar-keymap): Add optional arg KEYMAP (bug#50067). * lisp/mouse.el (context-menu-global): Use 'menu-bar-keymap' with its arg KEYMAP set to 'global-map'. --- lisp/menu-bar.el | 9 ++++++--- lisp/mouse.el | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'lisp/mouse.el') diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 1cc126b5017..f19dc9e7c97 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -2696,10 +2696,13 @@ This command is to be used when you click the mouse in the menubar." (cdr menu-bar-item-cons) 0)))) -(defun menu-bar-keymap () +(defun menu-bar-keymap (&optional keymap) "Return the current menu-bar keymap. +The ordering of the return value respects `menu-bar-final-items'. -The ordering of the return value respects `menu-bar-final-items'." +It's possible to use the KEYMAP argument to override the default keymap +that is the currently active maps. For example, the argument KEYMAP +could provide `global-map' where items are limited to the global map only." (let ((menu-bar '()) (menu-end '())) (map-keymap @@ -2712,7 +2715,7 @@ The ordering of the return value respects `menu-bar-final-items'." ;; sorting. (push (cons pos menu-item) menu-end) (push menu-item menu-bar)))) - (lookup-key (menu-bar-current-active-maps) [menu-bar])) + (lookup-key (or keymap (menu-bar-current-active-maps)) [menu-bar])) `(keymap ,@(nreverse menu-bar) ,@(mapcar #'cdr (sort menu-end (lambda (a b) diff --git a/lisp/mouse.el b/lisp/mouse.el index bcb58d153a8..7bac6dd07bf 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -364,7 +364,7 @@ Some context functions add menu items below the separator." (when (consp binding) (define-key-after menu (vector key) (copy-sequence binding)))) - (lookup-key global-map [menu-bar])) + (menu-bar-keymap global-map)) menu) (defun context-menu-local (menu _click) -- cgit v1.2.3 From 307d164c9c053501df8159719b3b502d720a945a Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 8 Nov 2021 21:23:44 +0200 Subject: * lisp/mouse.el (mouse-buffer-menu-mode-groups): Tighten "Version Control". Use word boundaries in the "Version Control" regexp to match mode names "Log-Edit", "Log-View", "Git-Log-View", "Change Log", "VC dir", but not "Verilog", "Prolog", "Rlogin" (bug#51337). --- lisp/mouse.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mouse.el') diff --git a/lisp/mouse.el b/lisp/mouse.el index 7bac6dd07bf..091383bf110 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -2466,7 +2466,7 @@ a large number if you prefer a mixed multitude. The default is 4." ("Text" . "Text") ("Outline" . "Text") ("\\(HT\\|SG\\|X\\|XHT\\)ML" . "SGML") - ("log\\|diff\\|vc\\|cvs\\|Git\\|Annotate" . "Version Control") + ("\\blog\\b\\|diff\\|\\bvc\\b\\|cvs\\|Git\\|Annotate" . "Version Control") ("Threads\\|Memory\\|Disassembly\\|Breakpoints\\|Frames\\|Locals\\|Registers\\|Inferior I/O\\|Debugger" . "GDB") ("Lisp" . "Lisp"))) -- cgit v1.2.3