commit b516887283ce77cf3c0977154f713ef485e3e8a9 (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Fri Jun 4 09:48:13 2021 +0300 Fix documentation of recent 'windmove' changes * lisp/windmove.el (windmove-default-keybindings) (windmove-display-default-keybindings) (windmove-delete-default-keybindings) (windmove-swap-states-default-keybindings): Improve doc strings. (Bug#41438) * etc/NEWS: Fix a typo in the 'windmove' entry. diff --git a/etc/NEWS b/etc/NEWS index 8b207001fe..675925906c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -557,8 +557,8 @@ disabled entirely. ** Windmove -*** New user options can be used to customize windmove keybindings. -There options include 'windmove-default-keybindings', +*** New user options to customize windmove keybindings. +These options include 'windmove-default-keybindings', 'windmove-display-default-keybindings', 'windmove-delete-default-keybindings', 'windmove-swap-states-default-keybindings'. diff --git a/lisp/windmove.el b/lisp/windmove.el index 0eba97a91b..f558903681 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -749,7 +749,8 @@ Default value of MODIFIERS is `shift-super'." "Customisation type for windmove modifiers.") (defcustom windmove-default-keybindings nil - "Default bindings for regular windmove commands." + "Default keybindings for regular windmove commands. +See `windmove-default-keybindings' for more detail." :set (lambda (sym val) (windmove-install-defaults (car val) (cdr val) @@ -764,7 +765,8 @@ Default value of MODIFIERS is `shift-super'." :group 'windmove) (defcustom windmove-display-default-keybindings nil - "Default bindings for display windmove commands." + "Default keybindings for windmove directional buffer display commands. +See `windmove-display-default-keybindings' for more detail." :set (lambda (sym val) (windmove-install-defaults (car val) (cdr val) @@ -782,7 +784,8 @@ Default value of MODIFIERS is `shift-super'." :group 'windmove) (defcustom windmove-delete-default-keybindings nil - "Default bindings for delete windmove commands." + "Default keybindings for windmove directional window deletion commands. +See `windmove-delete-default-keybindings' for more detail." :set (lambda (sym val) (windmove-install-defaults (car val) (cdr val) @@ -797,7 +800,8 @@ Default value of MODIFIERS is `shift-super'." :group 'windmove) (defcustom windmove-swap-states-default-keybindings nil - "Default bindings for swap-state windmove commands." + "Default keybindings for windmove's directional window swap-state commands. +See `windmove-swap-states-default-keybindings' for more detail." :set (lambda (sym val) (windmove-install-defaults (car val) (cdr val) commit 15c57fc4cc031cc6aca7eabd74706538fd6bfa22 Author: Juri Linkov Date: Thu Jun 3 23:54:30 2021 +0300 * lisp/simple.el (read-from-kill-ring): Fix the case of 'M-y M-p' (bug#48478) Don't use offsets for read-from-kill-ring-history when kill-ring-yank-pointer points to the last element of kill-ring. diff --git a/lisp/simple.el b/lisp/simple.el index 6d216f74d9..a0adaff431 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5742,7 +5742,8 @@ PROMPT is a string to prompt with." (complete-with-action action completions string pred))) nil nil nil (if history-pos - (cons 'read-from-kill-ring-history (1+ history-pos)) + (cons 'read-from-kill-ring-history + (if (zerop history-pos) history-pos (1+ history-pos))) 'read-from-kill-ring-history))))) (defcustom yank-from-kill-ring-rotate t commit d4ae640a3720e11fc8736a3530bba50520412023 Author: Juri Linkov Date: Thu Jun 3 23:41:30 2021 +0300 * lisp/help-fns.el (help--symbol-class): New function. Refactored from help--symbol-completion-table-affixation. https://lists.gnu.org/archive/html/emacs-devel/2021-06/msg00066.html diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 5a805a2302..133763add1 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -126,29 +126,35 @@ with the current prefix. The files are chosen according to :group 'help :version "26.3") +(defun help--symbol-class (s) + "Return symbol class characters for symbol S." + (when (stringp s) + (setq s (intern-soft s))) + (cond ((commandp s) + "c") ; command + ((eq (car-safe (symbol-function s)) 'macro) + "m") ; macro + ((fboundp s) + "f") ; function + ((custom-variable-p s) + "u") ; user option + ((boundp s) + "v") ; variable + ((facep s) + "a") ; fAce + ((and (fboundp 'cl-find-class) + (cl-find-class s)) + "t") ; CL type + (" ") ; something else + )) + (defun help--symbol-completion-table-affixation (completions) (mapcar (lambda (c) (let* ((s (intern c)) (doc (condition-case nil (documentation s) (error nil))) (doc (and doc (substring doc 0 (string-match "\n" doc))))) (list c (propertize - (concat (cond ((commandp s) - "c") ; command - ((eq (car-safe (symbol-function s)) 'macro) - "m") ; macro - ((fboundp s) - "f") ; function - ((custom-variable-p s) - "u") ; user option - ((boundp s) - "v") ; variable - ((facep s) - "a") ; fAce - ((and (fboundp 'cl-find-class) - (cl-find-class s)) - "t") ; CL type - (" ")) ; something else - " ") ; prefix separator + (concat (help--symbol-class s) " ") ; prefix separator 'face 'completions-annotations) (if doc (propertize (format " -- %s" doc) 'face 'completions-annotations) commit ee56a19873340c2e590fcb9ec8f2611e5ebbd794 Author: Juri Linkov Date: Thu Jun 3 23:36:07 2021 +0300 * etc/NEWS: Add windmove keybindings (bug#41438) diff --git a/etc/NEWS b/etc/NEWS index 3658f7fcd5..8b207001fe 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -555,6 +555,14 @@ disabled entirely. --- *** Autoload the main entry point 'mspool-show'. +** Windmove + +*** New user options can be used to customize windmove keybindings. +There options include 'windmove-default-keybindings', +'windmove-display-default-keybindings', +'windmove-delete-default-keybindings', +'windmove-swap-states-default-keybindings'. + ** Windows +++ commit 3916bf00c56274b39f921217168669f445e0df14 Author: Philip Kaludercic Date: Thu May 27 12:24:42 2021 +0200 Add user options for default windmove commands (bug#41438) * windmove.el (windmove--default-keybindings-type): Add type. (windmove-default-keybindings): Add user option. (windmove-display-default-keybindings): Add user option. (windmove-delete-default-keybindings): Add user option. (windmove-swap-states-default-keybindings): Add user option. diff --git a/lisp/windmove.el b/lisp/windmove.el index ea4486348b..0eba97a91b 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -731,6 +731,86 @@ Default value of MODIFIERS is `shift-super'." (windmove-swap-states-up up) (windmove-swap-states-down down)))) + + +(defconst windmove--default-keybindings-type + `(choice (const :tag "Don't bind" nil) + (cons :tag "Bind using" + (key-sequence :tag "Prefix") + (set :tag "Modifier" + :greedy t + ;; See `(elisp) Keyboard Events' + (const :tag "Meta" meta) + (const :tag "Control" control) + (const :tag "Shift" shift) + (const :tag "Hyper" hyper) + (const :tag "Super" super) + (const :tag "Alt" alt)))) + "Customisation type for windmove modifiers.") + +(defcustom windmove-default-keybindings nil + "Default bindings for regular windmove commands." + :set (lambda (sym val) + (windmove-install-defaults + (car val) (cdr val) + '((windmove-left left) + (windmove-right right) + (windmove-up up) + (windmove-down down)) + (null val)) + (set-default sym val)) + :type windmove--default-keybindings-type + :version "28.1" + :group 'windmove) + +(defcustom windmove-display-default-keybindings nil + "Default bindings for display windmove commands." + :set (lambda (sym val) + (windmove-install-defaults + (car val) (cdr val) + '((windmove-display-left left) + (windmove-display-right right) + (windmove-display-up up) + (windmove-display-down down) + (windmove-display-same-window ?0) + (windmove-display-new-frame ?f) + (windmove-display-new-tab ?t)) + (null val)) + (set-default sym val)) + :type windmove--default-keybindings-type + :version "28.1" + :group 'windmove) + +(defcustom windmove-delete-default-keybindings nil + "Default bindings for delete windmove commands." + :set (lambda (sym val) + (windmove-install-defaults + (car val) (cdr val) + '((windmove-delete-left left) + (windmove-delete-right right) + (windmove-delete-up up) + (windmove-delete-down down)) + (null val)) + (set-default sym val)) + :type windmove--default-keybindings-type + :version "28.1" + :group 'windmove) + +(defcustom windmove-swap-states-default-keybindings nil + "Default bindings for swap-state windmove commands." + :set (lambda (sym val) + (windmove-install-defaults + (car val) (cdr val) + '((windmove-swap-states-left left) + (windmove-swap-states-right right) + (windmove-swap-states-up up) + (windmove-swap-states-down down)) + (null val)) + (set-default sym val)) + :type windmove--default-keybindings-type + :version "28.1" + :group 'windmove) + (provide 'windmove) commit b5416d971a720e1dfb9aedd8e7d23f24b1ea5325 Author: Philip Kaludercic Date: Tue May 25 11:47:51 2021 +0200 Improve windmove-*-default-keybindings functions (bug#41438) * windmove.el (windmove-mode-map): Add special map for windmove commands. (windmove-mode): Add minor mode for activating windmove-mode-map. (windmove-install-defaults): Add general function for manipulating windmove-mode-map. (windmove-default-keybindings): Use windmove-install-defaults. (windmove-display-default-keybindings): Use windmove-install-defaults. (windmove-delete-default-keybindings): Use windmove-install-defaults. (windmove-swap-states-default-keybindings): Use windmove-install-defaults. diff --git a/lisp/windmove.el b/lisp/windmove.el index e4ea8e0f69..ea4486348b 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -426,19 +426,53 @@ unless `windmove-create-window' is non-nil and a new window is created." ;; I don't think these bindings will work on non-X terminals; you ;; probably want to use different bindings in that case. +(defvar windmove-mode-map (make-sparse-keymap) + "Map used by `windmove-install-defaults'.") + +(define-minor-mode windmove-mode + "Global minor mode for default windmove commands." + :keymap windmove-mode-map + :init-value t + :global t) + +(defun windmove-install-defaults (prefix modifiers alist &optional uninstall) + "Install keys as specified by ALIST. +Every element of ALIST has the form (FN KEY), where KEY is +appended to MODIFIERS, adding PREFIX to the beginning, before +installing the key. Previous bindings of FN are unbound. +If UNINSTALL is non-nil, just remove the keys from ALIST." + (dolist (bind alist) + (dolist (old (where-is-internal (car bind) windmove-mode-map)) + (define-key windmove-mode-map old nil)) + (unless uninstall + (let ((key (vconcat (if (or (equal prefix [ignore]) + (eq prefix 'none)) + nil prefix) + (list (append modifiers (cdr bind)))))) + (when (eq (key-binding key) #'self-insert-command) + (warn "Command %S is shadowing self-insert-key" (car bind))) + (let ((old-fn (lookup-key windmove-mode-map key))) + (when (functionp old-fn) + (warn "Overriding %S with %S" old-fn (car bind)))) + (define-key windmove-mode-map key (car bind)))))) + ;;;###autoload (defun windmove-default-keybindings (&optional modifiers) "Set up keybindings for `windmove'. Keybindings are of the form MODIFIERS-{left,right,up,down}, where MODIFIERS is either a list of modifiers or a single modifier. +If MODIFIERS is `none', the keybindings will be directly bound to +the arrow keys. Default value of MODIFIERS is `shift'." (interactive) (unless modifiers (setq modifiers 'shift)) + (when (eq modifiers 'none) (setq modifiers nil)) (unless (listp modifiers) (setq modifiers (list modifiers))) - (global-set-key (vector (append modifiers '(left))) 'windmove-left) - (global-set-key (vector (append modifiers '(right))) 'windmove-right) - (global-set-key (vector (append modifiers '(up))) 'windmove-up) - (global-set-key (vector (append modifiers '(down))) 'windmove-down)) + (windmove-install-defaults nil modifiers + '((windmove-left left) + (windmove-right right) + (windmove-up up) + (windmove-down down)))) ;;; Directional window display and selection @@ -546,17 +580,21 @@ See the logic of the prefix ARG in `windmove-display-in-direction'." Keys are bound to commands that display the next buffer in the specified direction. Keybindings are of the form MODIFIERS-{left,right,up,down}, where MODIFIERS is either a list of modifiers or a single modifier. +If MODIFIERS is `none', the keybindings will be directly bound to +the arrow keys. Default value of MODIFIERS is `shift-meta'." (interactive) (unless modifiers (setq modifiers '(shift meta))) + (when (eq modifiers 'none) (setq modifiers nil)) (unless (listp modifiers) (setq modifiers (list modifiers))) - (global-set-key (vector (append modifiers '(left))) 'windmove-display-left) - (global-set-key (vector (append modifiers '(right))) 'windmove-display-right) - (global-set-key (vector (append modifiers '(up))) 'windmove-display-up) - (global-set-key (vector (append modifiers '(down))) 'windmove-display-down) - (global-set-key (vector (append modifiers '(?0))) 'windmove-display-same-window) - (global-set-key (vector (append modifiers '(?f))) 'windmove-display-new-frame) - (global-set-key (vector (append modifiers '(?t))) 'windmove-display-new-tab)) + (windmove-install-defaults nil modifiers + '((windmove-display-left left) + (windmove-display-right right) + (windmove-display-up up) + (windmove-display-down down) + (windmove-display-same-window ?0) + (windmove-display-new-frame ?f) + (windmove-display-new-tab ?t)))) ;;; Directional window deletion @@ -618,16 +656,22 @@ select the window that was below the current one." Keys are bound to commands that delete windows in the specified direction. Keybindings are of the form PREFIX MODIFIERS-{left,right,up,down}, where PREFIX is a prefix key and MODIFIERS is either a list of modifiers or -a single modifier. Default value of PREFIX is `C-x' and MODIFIERS is `shift'." +a single modifier. +If PREFIX is `none', no prefix is used. If MODIFIERS is `none', the keybindings +are directly bound to the arrow keys. +Default value of PREFIX is `C-x' and MODIFIERS is `shift'." (interactive) (unless prefix (setq prefix '(?\C-x))) + (when (eq prefix 'none) (setq prefix nil)) (unless (listp prefix) (setq prefix (list prefix))) (unless modifiers (setq modifiers '(shift))) + (when (eq modifiers 'none) (setq modifiers nil)) (unless (listp modifiers) (setq modifiers (list modifiers))) - (global-set-key (vector prefix (append modifiers '(left))) 'windmove-delete-left) - (global-set-key (vector prefix (append modifiers '(right))) 'windmove-delete-right) - (global-set-key (vector prefix (append modifiers '(up))) 'windmove-delete-up) - (global-set-key (vector prefix (append modifiers '(down))) 'windmove-delete-down)) + (windmove-install-defaults prefix modifiers + '((windmove-delete-left left) + (windmove-delete-right right) + (windmove-delete-up up) + (windmove-delete-down down)))) ;;; Directional window swap states @@ -673,14 +717,19 @@ from the opposite side of the frame." Keys are bound to commands that swap the states of the selected window with the window in the specified direction. Keybindings are of the form MODIFIERS-{left,right,up,down}, where MODIFIERS is either a list of modifiers -or a single modifier. Default value of MODIFIERS is `shift-super'." +or a single modifier. +If MODIFIERS is `none', the keybindings will be directly bound to the +arrow keys. +Default value of MODIFIERS is `shift-super'." (interactive) (unless modifiers (setq modifiers '(shift super))) + (when (eq modifiers 'none) (setq modifiers nil)) (unless (listp modifiers) (setq modifiers (list modifiers))) - (global-set-key (vector (append modifiers '(left))) 'windmove-swap-states-left) - (global-set-key (vector (append modifiers '(right))) 'windmove-swap-states-right) - (global-set-key (vector (append modifiers '(up))) 'windmove-swap-states-up) - (global-set-key (vector (append modifiers '(down))) 'windmove-swap-states-down)) + (windmove-install-defaults nil modifiers + '((windmove-swap-states-left left) + (windmove-swap-states-right right) + (windmove-swap-states-up up) + (windmove-swap-states-down down)))) (provide 'windmove) commit 6b41d7da9543786647218fe89224809cc51d25d3 Author: Mattias EngdegÄrd Date: Thu Jun 3 21:20:57 2021 +0200 Constant-propagate (function SYMBOL) * lisp/emacs-lisp/byte-opt.el (byte-optimize--substitutable-p): Consider #'SYMBOL a constant for compile-time propagation purposes. diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 99e84e23ad..2fff0bd4a5 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -343,7 +343,7 @@ Same format as `byte-optimize--lexvars', with shared structure and contents.") (numberp expr) (stringp expr) (and (consp expr) - (eq (car expr) 'quote) + (memq (car expr) '(quote function)) (symbolp (cadr expr))) (keywordp expr))) commit a517b77ffe8ed8cdfeec1a9b5258fd16b2446214 Author: Mattias EngdegÄrd Date: Thu Jun 3 21:15:11 2021 +0200 Optimise (cons X nil) to (list X) * lisp/emacs-lisp/byte-opt.el (byte-optimize-cons): New function. diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 10a50da462..99e84e23ad 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -1269,6 +1269,14 @@ See Info node `(elisp) Integer Basics'." form) form)) +(put 'cons 'byte-optimizer #'byte-optimize-cons) +(defun byte-optimize-cons (form) + ;; (cons X nil) => (list X) + (if (and (= (safe-length form) 3) + (null (nth 2 form))) + `(list ,(nth 1 form)) + form)) + ;; Fixme: delete-char -> delete-region (byte-coded) ;; optimize string-as-unibyte, string-as-multibyte, string-make-unibyte, ;; string-make-multibyte for constant args. commit c3b44858dc9d9eeda4863ed6ffafbeb446374465 Author: Eli Zaretskii Date: Thu Jun 3 17:45:12 2021 +0300 Fix fill-column-indicator on TTY frames * src/xdisp.c (extend_face_to_end_of_line): Fix calculation of fill-column-indicator on TTY frames. Suggested by Jimmy Aguilar Mena . diff --git a/src/xdisp.c b/src/xdisp.c index 0e8672961a..e761ef8b37 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -22386,15 +22386,23 @@ extend_face_to_end_of_line (struct it *it) it->face_id = (it->glyph_row->ends_at_zv_p ? default_face->id : face->id); - /* Display fill-column indicator if needed. */ - const int indicator_column = fill_column_indicator_column (it, 1); - /* Make sure our idea of current_x is in sync with the glyphs actually in the glyph row. They might differ because append_space_for_newline can insert one glyph without updating current_x. */ it->current_x = it->glyph_row->used[TEXT_AREA]; + /* The above assignment causes the code below to use a + non-standard semantics of it->current_x: it is measured + relative to the beginning of the text-area, thus disregarding + the window's hscroll. That is why we need to correct the + indicator column for the hscroll, otherwise the indicator + will not move together with the text as result of horizontal + scrolling. */ + const int indicator_column = + fill_column_indicator_column (it, 1) - it->first_visible_x; + + /* Display fill-column indicator if needed. */ while (it->current_x <= it->last_visible_x) { if (it->current_x != indicator_column) commit 528e15775e1fa52f591681340f9d7772aa38b97e Author: Eli Zaretskii Date: Thu Jun 3 15:57:14 2021 +0300 More accurate highlighting of mis-spellings in Flyspell * lisp/textmodes/flyspell.el (flyspell-word): Highlight only the misspelled word, not any extra characters after it. (Bug#5575) diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 8d2715f611..ba48e5de21 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -1263,14 +1263,27 @@ spell-check." (t (setq flyspell-word-cache-result nil) ;; Highlight the location as incorrect, - ;; including offset specified in POSS. + ;; including offset specified in POSS + ;; and only for the length of the + ;; misspelled word specified by POSS. (if flyspell-highlight-flag - (flyspell-highlight-incorrect-region - (if (and (consp poss) - (integerp (nth 1 poss))) - (+ start (nth 1 poss) -1) - start) - end poss) + (let ((hstart start) + (hend end) + offset misspelled) + (when (consp poss) + (setq misspelled (car poss) + offset (nth 1 poss)) + (if (integerp offset) + (setq hstart (+ start offset -1))) + ;; POSS includes the misspelled + ;; word; use that to figure out + ;; how many characters to highlight. + (if (stringp misspelled) + (setq hend + (+ hstart + (length misspelled))))) + (flyspell-highlight-incorrect-region + hstart hend poss)) (flyspell-notify-misspell word poss)) nil)))) ;; return to original location commit 089e0c4c55dcf72f9cf2f6f04b8a52fc7355499c Author: Lars Ingebrigtsen Date: Thu Jun 3 11:55:45 2021 +0200 Make the `i' command in Info-mode remove duplicate matches * lisp/info.el (Info-index): Weed out duplicate matched (bug#3692). diff --git a/lisp/info.el b/lisp/info.el index cdf339ff6f..83a9bfbc23 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -3375,7 +3375,13 @@ Give an empty topic name to go to the Index node itself." (setq exact (cons found exact) matches (delq found matches))) (setq Info-history-list ohist-list) - (setq Info-index-alternatives (nconc exact (nreverse matches))) + (setq Info-index-alternatives + ;; Weed out index entries that refer to the same line. + (seq-uniq + (nconc exact (nreverse matches)) + (lambda (m1 m2) + (and (equal (nth 1 m1) (nth 1 m2)) + (equal (nth 3 m1) (nth 3 m2)))))) (Info-index-next 0))))) (defun Info-index-next (num)