commit 05740f05b732a5df473bdf9d1750e97f6a86f2c0 (HEAD, refs/remotes/origin/master) Merge: e871f21348a 12b2b8864c2 Author: Stefan Kangas Date: Wed Dec 21 06:30:10 2022 +0100 Merge from origin/emacs-29 12b2b8864c2 Fix empty pairs in js tree-sitter imenu alist (bug#59945) 6d9f367ead3 ; * lisp/treesit.el (treesit-simple-indent-presets): Fix ... commit 12b2b8864c295ce27594e8a907ebb3423e58a9d4 (refs/remotes/origin/emacs-29) Author: Charl P. Botha Date: Sat Dec 10 19:09:38 2022 +0200 Fix empty pairs in js tree-sitter imenu alist (bug#59945) The current js--treesit-imenu, used by the JavaScript, TypeScript and TSX tree-sitter modes, would return empty pairs in the imenu alist if there were none of that type of symbol. This would break both the built in imenu and also packages like consult-imenu. See https://github.com/minad/consult/issues/697 for the discussion there. * lisp/progmodes/js.el (js--treesit-imenu): Don't add nil indexes. Copyright-paperwork-exempt: yes diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 8c1ee495c2d..1b34c0de418 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3738,9 +3738,14 @@ js--treesit-imenu node "function_declaration" nil 1000)) (var-tree (treesit-induce-sparse-tree node "lexical_declaration" nil 1000))) - `(("Class" . ,(js--treesit-imenu-1 class-tree)) - ("Variable" . ,(js--treesit-imenu-1 var-tree)) - ("Function" . ,(js--treesit-imenu-1 func-tree))))) + ;; When a sub-tree is empty, we should not return that pair at all. + (append + (and func-tree + `(("Function" . ,(js--treesit-imenu-1 func-tree)))) + (and var-tree + `(("Variable" . ,(js--treesit-imenu-1 var-tree)))) + (and class-tree + `(("Class" . ,(js--treesit-imenu-1 class-tree))))))) ;;; Main Function commit 6d9f367ead32c688bcfc6a0366073dff6740099c Author: Yuan Fu Date: Mon Dec 19 17:54:12 2022 -0800 ; * lisp/treesit.el (treesit-simple-indent-presets): Fix typo. diff --git a/lisp/treesit.el b/lisp/treesit.el index 82757d298e8..64076691186 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1183,7 +1183,7 @@ treesit-simple-indent-presets \(n-p-gp NODE-TYPE PARENT-TYPE GRANDPARENT-TYPE) - Checks that NODE, its parent, and its grandparent's type. + Checks for NODE's, its parent's, and its grandparent's type. \(query QUERY) commit e871f21348a737541b181445c911dd58c34e9a47 Author: Stefan Kangas Date: Wed Dec 21 02:38:13 2022 +0100 ; Manually fix merge errors in etc/NEWS diff --git a/etc/NEWS b/etc/NEWS index dd1f1bbf24f..af7f1050b76 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -71,9 +71,6 @@ switches for shortlogs, such as the one produced by 'C-x v L'. You can now configure how to display the "*buffer-selection*" buffer using this new option. (Or set 'display-buffer-alist' directly.) ---- -*** New user option 'ruby-method-params-indent'. - ** Eshell +++ diff --git a/etc/NEWS.29 b/etc/NEWS.29 index 017fd850b4e..0e844596347 100644 --- a/etc/NEWS.29 +++ b/etc/NEWS.29 @@ -2761,6 +2761,9 @@ project-dedicated or global) is specified by the new --- *** Support for endless methods. +--- +*** New user option 'ruby-method-params-indent'. + ** Eshell +++ commit 2bbc554db63cc5cc140ade5bfcbbf53ecd18f5ae Merge: 1424342225e d3a76db88b4 Author: Stefan Kangas Date: Wed Dec 21 02:37:17 2022 +0100 Merge from origin/emacs-29 d3a76db88b4 * lisp/repeat.el: Fix repeat-keep-prefix to allow customi... 8ef3777d544 Correct capitalization of Lisp in the manual (bug#60222) d03ea893780 eglot.el: Add vscode-json-languageserver to eglot-server-... 8550a993785 ; * src/emacs-module.h.in (enum emacs_funcall_exit): Fix ... fb7f3999c59 ; Fix ruby-method-params-indent's :version value cfbfd393b45 * lisp/progmodes/project.el (project--read-file-cpd-relat... 2b1fdbffcb5 ruby-method-params-indent: New user option b9e813f79f2 ; ruby-indent-level: Improve the docstring 399433cc2b9 * lisp/progmodes/project.el: Filter out empty strings fro... 23f7c9c2a92 Fix storing email into nnmail by Gnus 63cdbd986bb ; Really respect browse-url var in erc-compat 64163618d21 whitespace: Fix unintended change in buffer modification ... a75d1da911c Make emacsclient add abbreviated file names to file-name-... b3e7768a0ee Repair setopt test after error demotion to warning commit 1424342225ef5b18c630364dd88e004f4ebb1c7f Author: Sean Whitton Date: Tue Dec 20 15:53:19 2022 -0700 vc-git-checkin: Don't try to apply an empty patch * lisp/vc/vc-git.el (vc-git-checkin): Don't try to apply an empty patch to the index, because in that case 'git apply' fails. diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 8f995021dcc..0a4e9caa614 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1056,12 +1056,13 @@ vc-git-checkin (vc-git-command nil 0 file-name "reset" "-q" "--")) (t (user-error "Index not empty"))) (setq pos (point)))))) - (let ((patch-file (make-nearby-temp-file "git-patch"))) - (with-temp-file patch-file - (insert vc-git-patch-string)) - (unwind-protect - (vc-git-command nil 0 patch-file "apply" "--cached") - (delete-file patch-file)))) + (unless (string-empty-p vc-git-patch-string) + (let ((patch-file (make-nearby-temp-file "git-patch"))) + (with-temp-file patch-file + (insert vc-git-patch-string)) + (unwind-protect + (vc-git-command nil 0 patch-file "apply" "--cached") + (delete-file patch-file))))) (cl-flet ((boolean-arg-fn (argument) (lambda (value) (when (equal value "yes") (list argument))))) commit 962bdfcdfe7e27687021c7dbaf0bb292afe9483c Author: Sean Whitton Date: Fri Dec 16 11:28:20 2022 -0700 vc-git-checkin: Offer to unstage conflicting changes * lisp/vc/vc-git.el (vc-git-checkin): When committing a patch, if conflicting changes are already staged, offer to clear them, instead of just immediately failing with "Index not empty" (bug#60126). diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 9f27f759d35..8f995021dcc 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1030,23 +1030,31 @@ vc-git-checkin (with-temp-buffer (vc-git-command (current-buffer) t nil "diff" "--cached") (goto-char (point-min)) - (let ((pos (point)) file-diff file-beg) + (let ((pos (point)) file-name file-diff file-beg) (while (not (eobp)) + (when (and (looking-at "^diff --git a/\\(.+\\) b/\\(.+\\)") + (string= (match-string 1) (match-string 2))) + (setq file-name (match-string 1))) (forward-line 1) ; skip current "diff --git" line (search-forward "diff --git" nil 'move) (move-beginning-of-line 1) (setq file-diff (buffer-substring pos (point))) - (if (and (setq file-beg (string-search - file-diff vc-git-patch-string)) - ;; Check that file diff ends with an empty string - ;; or the beginning of the next file diff. - (string-match-p "\\`\\'\\|\\`diff --git" - (substring - vc-git-patch-string - (+ file-beg (length file-diff))))) - (setq vc-git-patch-string - (string-replace file-diff "" vc-git-patch-string)) - (user-error "Index not empty")) + (cond ((and (setq file-beg (string-search + file-diff vc-git-patch-string)) + ;; Check that file diff ends with an empty string + ;; or the beginning of the next file diff. + (string-match-p "\\`\\'\\|\\`diff --git" + (substring + vc-git-patch-string + (+ file-beg (length file-diff))))) + (setq vc-git-patch-string + (string-replace file-diff "" vc-git-patch-string))) + ((and file-name + (yes-or-no-p + (format "Unstage already-staged changes to %s?" + file-name))) + (vc-git-command nil 0 file-name "reset" "-q" "--")) + (t (user-error "Index not empty"))) (setq pos (point)))))) (let ((patch-file (make-nearby-temp-file "git-patch"))) (with-temp-file patch-file commit d3a76db88b4357fe1c92f240796ea9b522b97a8e Author: Juri Linkov Date: Tue Dec 20 19:22:15 2022 +0200 * lisp/repeat.el: Fix repeat-keep-prefix to allow customizing it to non-nil. * lisp/repeat.el (repeat-keep-prefix): Add or remove 'repeat-pre-hook' depending on the customized value. (repeat-mode): Add or remove 'repeat-pre-hook' to/from 'pre-command-hook' when 'repeat-keep-prefix' is non-nil. (repeat-pre-hook): New function. (repeat-get-map, repeat-check-map): New function refactored from 'repeat-post-hook'. (repeat-post-hook): Move some code to smaller functions. (describe-repeat-maps): Set outline-regexp without ^L. * test/lisp/repeat-tests.el (repeat-tests-keep-prefix): Uncomment test case that is fixed now in bug#51281 and bug#55986. diff --git a/lisp/repeat.el b/lisp/repeat.el index 33e8d98ce33..3b3a444ee24 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -368,6 +368,13 @@ repeat-exit-timer (defcustom repeat-keep-prefix nil "Whether to keep the prefix arg of the previous command when repeating." :type 'boolean + :initialize #'custom-initialize-default + :set (lambda (sym val) + (set-default sym val) + (when repeat-mode + (if repeat-keep-prefix + (add-hook 'pre-command-hook 'repeat-pre-hook) + (remove-hook 'pre-command-hook 'repeat-pre-hook)))) :group 'repeat :version "28.1") @@ -419,7 +426,11 @@ repeat-mode See `describe-repeat-maps' for a list of all repeatable commands." :global t :group 'repeat (if (not repeat-mode) - (remove-hook 'post-command-hook 'repeat-post-hook) + (progn + (remove-hook 'pre-command-hook 'repeat-pre-hook) + (remove-hook 'post-command-hook 'repeat-post-hook)) + (when repeat-keep-prefix + (add-hook 'pre-command-hook 'repeat-pre-hook)) (add-hook 'post-command-hook 'repeat-post-hook) (let* ((keymaps nil) (commands (all-completions @@ -431,15 +442,21 @@ repeat-mode (length commands) (length (delete-dups keymaps)))))) -(defvar repeat--prev-mb '(0) - "Previous minibuffer state.") - (defun repeat--command-property (property) (or (and (symbolp this-command) (get this-command property)) (and (symbolp real-this-command) (get real-this-command property)))) +(defun repeat-get-map () + "Return a transient map for keys repeatable after the current command." + (when repeat-mode + (let ((rep-map (or repeat-map (repeat--command-property 'repeat-map)))) + (when rep-map + (when (and (symbolp rep-map) (boundp rep-map)) + (setq rep-map (symbol-value rep-map))) + rep-map)))) + (defun repeat-check-key (key map) "Check if the last key is suitable to activate the repeating MAP." (let* ((prop (repeat--command-property 'repeat-check-key)) @@ -449,50 +466,61 @@ repeat-check-key ;; Try without modifiers: (lookup-key map (vector (event-basic-type key)))))) +(defvar repeat--prev-mb '(0) + "Previous minibuffer state.") + +(defun repeat-check-map (map) + "Decides whether MAP can be used for the next command." + (and map + ;; Detect changes in the minibuffer state to allow repetitions + ;; in the same minibuffer, but not when the minibuffer is activated + ;; in the middle of repeating sequence (bug#47566). + (or (< (minibuffer-depth) (car repeat--prev-mb)) + (eq current-minibuffer-command (cdr repeat--prev-mb))) + (repeat-check-key last-command-event map) + t)) + +(defun repeat-pre-hook () + "Function run before commands to handle repeatable keys." + (when (and repeat-mode repeat-keep-prefix repeat-in-progress + (not prefix-arg) current-prefix-arg) + (let ((map (repeat-get-map))) + ;; Only when repeat-post-hook will activate the same map + (when (repeat-check-map map) + ;; Optimize to use less logic in the function `repeat-get-map' + ;; for the next call: when called again from `repeat-post-hook' + ;; it will use the variable `repeat-map'. + (setq repeat-map map) + ;; Preserve universal argument + (setq prefix-arg current-prefix-arg))))) + (defun repeat-post-hook () "Function run after commands to set transient keymap for repeatable keys." (let ((was-in-progress repeat-in-progress)) (setq repeat-in-progress nil) - (when repeat-mode - (let ((rep-map (or repeat-map (repeat--command-property 'repeat-map)))) - (when rep-map - (when (and (symbolp rep-map) (boundp rep-map)) - (setq rep-map (symbol-value rep-map))) - (let ((map (copy-keymap rep-map))) - - (when (and - ;; Detect changes in the minibuffer state to allow repetitions - ;; in the same minibuffer, but not when the minibuffer is activated - ;; in the middle of repeating sequence (bug#47566). - (or (< (minibuffer-depth) (car repeat--prev-mb)) - (eq current-minibuffer-command (cdr repeat--prev-mb))) - (or (not repeat-keep-prefix) prefix-arg) - (repeat-check-key last-command-event map)) - - ;; Messaging - (unless prefix-arg - (funcall repeat-echo-function map)) - - ;; Adding an exit key - (when repeat-exit-key - (define-key map (if (key-valid-p repeat-exit-key) - (kbd repeat-exit-key) - repeat-exit-key) - 'ignore)) - - (when (and repeat-keep-prefix (not prefix-arg)) - (setq prefix-arg current-prefix-arg)) - - (setq repeat-in-progress t) - (let ((exitfun (set-transient-map map))) - (repeat--exit) - (setq repeat-exit-function exitfun) - - (let* ((prop (repeat--command-property 'repeat-exit-timeout)) - (timeout (unless (eq prop 'no) (or prop repeat-exit-timeout)))) - (when timeout - (setq repeat-exit-timer - (run-with-idle-timer timeout nil #'repeat-exit)))))))))) + (let ((map (repeat-get-map))) + (when (repeat-check-map map) + ;; Messaging + (funcall repeat-echo-function map) + + ;; Adding an exit key + (when repeat-exit-key + (setq map (copy-keymap map)) + (define-key map (if (key-valid-p repeat-exit-key) + (kbd repeat-exit-key) + repeat-exit-key) + 'ignore)) + + (setq repeat-in-progress t) + (repeat--exit) + (let ((exitfun (set-transient-map map))) + (setq repeat-exit-function exitfun) + + (let* ((prop (repeat--command-property 'repeat-exit-timeout)) + (timeout (unless (eq prop 'no) (or prop repeat-exit-timeout)))) + (when timeout + (setq repeat-exit-timer + (run-with-idle-timer timeout nil #'repeat-exit))))))) (setq repeat-map nil) (setq repeat--prev-mb (cons (minibuffer-depth) current-minibuffer-command)) @@ -582,6 +610,7 @@ describe-repeat-maps (push s (alist-get (get s 'repeat-map) keymaps))))) (with-help-window (help-buffer) (with-current-buffer standard-output + (setq-local outline-regexp "[*]+") (insert "A list of keymaps used by commands with the symbol property `repeat-map'.\n") (dolist (keymap (sort keymaps (lambda (a b) diff --git a/test/lisp/repeat-tests.el b/test/lisp/repeat-tests.el index 1382d003599..06c6f748a2a 100644 --- a/test/lisp/repeat-tests.el +++ b/test/lisp/repeat-tests.el @@ -76,27 +76,27 @@ repeat-tests-check-key "C-x w a b a c" '((1 a) (1 b) (1 a)) "c") (repeat-tests--check - "M-C-a b a c" + "C-M-a b a c" '((1 a) (1 b) (1 a)) "c") (repeat-tests--check - "M-C-z b a c" + "C-M-z b a c" '((1 a)) "bac") (unwind-protect (progn (put 'repeat-tests-call-a 'repeat-check-key 'no) (repeat-tests--check - "M-C-z b a c" + "C-M-z b a c" '((1 a) (1 b) (1 a)) "c")) (put 'repeat-tests-call-a 'repeat-check-key nil))) (let ((repeat-check-key nil)) (repeat-tests--check - "M-C-z b a c" + "C-M-z b a c" '((1 a) (1 b) (1 a)) "c") (unwind-protect (progn (put 'repeat-tests-call-a 'repeat-check-key t) (repeat-tests--check - "M-C-z b a c" + "C-M-z b a c" '((1 a)) "bac")) (put 'repeat-tests-call-a 'repeat-check-key nil)))))) @@ -125,15 +125,17 @@ repeat-tests-keep-prefix (repeat-tests--check "C-2 C-x w a C-3 c" '((2 a)) "ccc")) - ;; TODO: fix and uncomment - ;; (let ((repeat-keep-prefix t)) - ;; (repeat-tests--check - ;; "C-2 C-x w a b a b c" - ;; '((2 a) (2 b) (2 a) (2 b)) "c") - ;; (repeat-tests--check - ;; "C-2 C-x w a C-1 C-2 b a C-3 C-4 b c" - ;; '((2 a) (12 b) (12 a) (34 b)) "c")) - ))) + ;; Fixed in bug#51281 and bug#55986 + (let ((repeat-keep-prefix t)) + ;; Re-enable to take effect. + (repeat-mode -1) (repeat-mode +1) + (repeat-tests--check + "C-2 C-x w a b a b c" + '((2 a) (2 b) (2 a) (2 b)) "c") + ;; (repeat-tests--check + ;; "C-2 C-x w a C-1 C-2 b a C-3 C-4 b c" + ;; '((2 a) (12 b) (12 a) (34 b)) "c") + )))) ;; TODO: :tags '(:expensive-test) for repeat-exit-timeout commit 9fafeb2a66fe1cba8f3ad7662196e36ca0b1eca7 Author: Vibhav Pant Date: Tue Dec 20 21:29:54 2022 +0530 Ensure that we are not aset-ing Lisp records in purespace. * src/data.c (Faset): Enforce that Lisp records passed to aset are impure with CHECK_IMPURE. diff --git a/src/data.c b/src/data.c index c6b85e17bc2..7ad06a9faa5 100644 --- a/src/data.c +++ b/src/data.c @@ -2619,6 +2619,7 @@ DEFUN ("aset", Faset, Saset, 3, 3, 0, } else if (RECORDP (array)) { + CHECK_IMPURE (array, XVECTOR (array)); if (idxval < 0 || idxval >= PVSIZE (array)) args_out_of_range (array, idx); ASET (array, idxval, newelt); commit 8ef3777d54429744dc941145c25067d6964374aa Author: Daniel Martín Date: Tue Dec 20 16:32:37 2022 +0100 Correct capitalization of Lisp in the manual (bug#60222) * doc/lispref/compile.texi (Native-Compilation Functions): Fix typo. diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index 3e397349995..ae4905bb1f9 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi @@ -930,7 +930,7 @@ Native-Compilation Functions file that is loaded into Emacs, when no natively-compiled file for it is available. Note that because of this use of a subprocess, native compilation may produce warning and errors which byte-compilation does -not, and lisp code may thus need to be modified to work correctly. See +not, and Lisp code may thus need to be modified to work correctly. See @code{native-comp-async-report-warnings-errors} in @pxref{Native-Compilation Variables} for more details. commit d03ea8937803c6714df71dd148c79ca893d159e9 Author: Brian Leung Date: Mon Dec 19 15:03:06 2022 -0800 eglot.el: Add vscode-json-languageserver to eglot-server-programs * lisp/progmodes/eglot.el (eglot-server-programs): Add the alternative name of the vcscode JSON server. (Bug#60198) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index ce4ca4f3d92..0f1bfd0447d 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -190,6 +190,7 @@ eglot-server-programs '("pylsp" "pyls" ("pyright-langserver" "--stdio") "jedi-language-server"))) ((js-json-mode json-mode json-ts-mode) . ,(eglot-alternatives '(("vscode-json-language-server" "--stdio") + ("vscode-json-languageserver" "--stdio") ("json-languageserver" "--stdio")))) ((js-mode js-ts-mode tsx-ts-mode typescript-ts-mode typescript-mode) . ("typescript-language-server" "--stdio")) commit 8550a9937858e4524acd43015b28a42a707d26fc Author: Philipp Stephani Date: Tue Dec 20 13:29:49 2022 +0100 ; * src/emacs-module.h.in (enum emacs_funcall_exit): Fix typo. diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in index bef89b059fc..22096db7e85 100644 --- a/src/emacs-module.h.in +++ b/src/emacs-module.h.in @@ -116,7 +116,7 @@ enum emacs_funcall_exit /* Function has signaled an error using `signal'. */ emacs_funcall_exit_signal = 1, - /* Function has exit using `throw'. */ + /* Function has exited using `throw'. */ emacs_funcall_exit_throw = 2 }; commit 8d6fb6498ab457e92b08e26203b585ba989a7844 Author: Stefan Kangas Date: Tue Dec 20 11:43:30 2022 +0100 ; Revert UK->US spelling fix in rx.el * lisp/emacs-lisp/rx.el (rx--normalise-or-arg): Revert to British spelling of internal symbol. diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 2ebdbc0efc4..f2a0dc54832 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -254,20 +254,20 @@ rx--foldl (setq l (cdr l))) x) -(defun rx--normalize-or-arg (form) +(defun rx--normalise-or-arg (form) "Normalize the `or' argument FORM. Characters become strings, user-definitions and `eval' forms are expanded, and `or' forms are normalized recursively." (cond ((characterp form) (char-to-string form)) ((and (consp form) (memq (car form) '(or |))) - (cons (car form) (mapcar #'rx--normalize-or-arg (cdr form)))) + (cons (car form) (mapcar #'rx--normalise-or-arg (cdr form)))) ((and (consp form) (eq (car form) 'eval)) - (rx--normalize-or-arg (rx--expand-eval (cdr form)))) + (rx--normalise-or-arg (rx--expand-eval (cdr form)))) (t (let ((expanded (rx--expand-def form))) (if expanded - (rx--normalize-or-arg expanded) + (rx--normalise-or-arg expanded) form))))) (defun rx--all-string-or-args (body) @@ -302,7 +302,7 @@ rx--translate-or ((null (cdr body)) ; Single item. (rx--translate (car body))) (t - (let* ((args (mapcar #'rx--normalize-or-arg body)) + (let* ((args (mapcar #'rx--normalise-or-arg body)) (all-strings (catch 'rx--nonstring (rx--all-string-or-args args)))) (cond (all-strings ; Only strings. @@ -1494,9 +1494,6 @@ rx--pcase-expand ;; Obsolete internal symbol, used in old versions of the `flycheck' package. (define-obsolete-function-alias 'rx-submatch-n 'rx-to-string "27.1") -(define-obsolete-function-alias 'rx--normalise-or-arg - #'rx--normalize-or-arg "30.1") - (provide 'rx) ;;; rx.el ends here commit fb7f3999c59ce3a1b08bca8d8b79db885fd3550f Author: Dmitry Gutov Date: Tue Dec 20 02:58:48 2022 +0200 ; Fix ruby-method-params-indent's :version value diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 2b813dfcbcc..1f3e9b6ae7b 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -283,7 +283,7 @@ ruby-method-params-indent (number :tag "Indent specified number of columns against def") (const :tag "Indent to def" nil)) :safe (lambda (val) (or (memq val '(t nil)) (numberp val))) - :version 29.1) + :version "29.1") (defcustom ruby-deep-arglist t "Deep indent lists in parenthesis when non-nil. commit cfbfd393b450d4eb7ac0b7922b44208688553c9e Author: Juri Linkov Date: Mon Dec 19 21:46:40 2022 +0200 * lisp/progmodes/project.el (project--read-file-cpd-relative): Optimize. diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 605636d93e3..c2633798473 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1040,13 +1040,14 @@ project--read-file-cpd-relative (setq substrings (cons "./" substrings)))) (new-collection (project--file-completion-table substrings)) (abbr-cpd (abbreviate-file-name common-parent-directory)) + (abbr-cpd-length (length abbr-cpd)) (relname (cl-letf ((history-add-new-input nil) ((symbol-value hist) (mapcan (lambda (s) (and (string-prefix-p abbr-cpd s) - (not (eq (length abbr-cpd) (length s))) - (list (substring s (length abbr-cpd))))) + (not (eq abbr-cpd-length (length s))) + (list (substring s abbr-cpd-length)))) (symbol-value hist)))) (project--completing-read-strict prompt new-collection commit 2b1fdbffcb595bcd72fa9aa3db674c6985042bcb Author: Dmitry Gutov Date: Mon Dec 19 21:01:27 2022 +0200 ruby-method-params-indent: New user option * lisp/progmodes/ruby-mode.el (ruby-method-params-indent): New option (bug#60110). (ruby-smie-rules): Use it. * etc/NEWS: Mention it. * test/lisp/progmodes/ruby-mode-resources/ruby.rb: Ensure the var's value is default. * test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb: New file. * test/lisp/progmodes/ruby-mode-tests.el (ruby-deftest-indent): New macro, use it to run the indentation test using the new file. Disable the :expensive-test tag, because neither runs for "longer than some few seconds", both take significantly below 1s. diff --git a/etc/NEWS b/etc/NEWS index 017fd850b4e..0e844596347 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2761,6 +2761,9 @@ project-dedicated or global) is specified by the new --- *** Support for endless methods. +--- +*** New user option 'ruby-method-params-indent'. + ** Eshell +++ diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index d7efe982870..2b813dfcbcc 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -268,6 +268,23 @@ ruby-align-chained-calls :safe 'booleanp :version "24.4") +(defcustom ruby-method-params-indent t + "Indentation of multiline method parameters. + +When t, the parameters list is indented to the method name. + +When a number, indent the parameters list this many columns +against the beginning of the method (the \"def\" keyword). + +The value nil means the same as 0. + +Only has effect when `ruby-use-smie' is t." + :type '(choice (const :tag "Indent to the method name" t) + (number :tag "Indent specified number of columns against def") + (const :tag "Indent to def" nil)) + :safe (lambda (val) (or (memq val '(t nil)) (numberp val))) + :version 29.1) + (defcustom ruby-deep-arglist t "Deep indent lists in parenthesis when non-nil. Also ignores spaces after parenthesis when `space'. @@ -660,9 +677,12 @@ ruby-smie-rules (unless (or (eolp) (forward-comment 1)) (cons 'column (current-column))))) ('(:before . " @ ") - (save-excursion - (skip-chars-forward " \t") - (cons 'column (current-column)))) + (if (or (eq ruby-method-params-indent t) + (not (smie-rule-parent-p "def" "def="))) + (save-excursion + (skip-chars-forward " \t") + (cons 'column (current-column))) + (smie-rule-parent (or ruby-method-params-indent 0)))) ('(:before . "do") (ruby-smie--indent-to-stmt)) ('(:before . ".") (if (smie-rule-sibling-p) diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb b/test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb new file mode 100644 index 00000000000..2b665797397 --- /dev/null +++ b/test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb @@ -0,0 +1,18 @@ +class C + def self.foo( + baz, + bar + ) = + what + + def foo=( + baz, + bar + ) + hello + end +end + +# Local Variables: +# ruby-method-params-indent: 0 +# End: diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb b/test/lisp/progmodes/ruby-mode-resources/ruby.rb index 2451edaee22..6a69d9db78a 100644 --- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb +++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb @@ -538,3 +538,7 @@ def baz.full_name = "#{bar} 3" baz end end + +# Local Variables: +# ruby-method-params-indent: t +# End: diff --git a/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el index 9be01dc78f9..560f780285a 100644 --- a/test/lisp/progmodes/ruby-mode-tests.el +++ b/test/lisp/progmodes/ruby-mode-tests.el @@ -943,16 +943,20 @@ ruby-imenu-with-private-modifier "Blub#bye" "Blub#hiding"))))) -(ert-deftest ruby--indent/converted-from-manual-test () - :tags '(:expensive-test) - ;; Converted from manual test. - (let ((buf (find-file-noselect (ert-resource-file "ruby.rb")))) - (unwind-protect - (with-current-buffer buf - (let ((orig (buffer-string))) - (indent-region (point-min) (point-max)) - (should (equal (buffer-string) orig)))) - (kill-buffer buf)))) +(defmacro ruby-deftest-indent (file) + `(ert-deftest ,(intern (format "ruby-indent-test/%s" file)) () + ;; :tags '(:expensive-test) + (let ((buf (find-file-noselect (ert-resource-file ,file)))) + (unwind-protect + (with-current-buffer buf + (let ((orig (buffer-string))) + ;; Indent and check that we get the original text. + (indent-region (point-min) (point-max)) + (should (equal (buffer-string) orig)))) + (kill-buffer buf))))) + +(ruby-deftest-indent "ruby.rb") +(ruby-deftest-indent "ruby-method-params-indent.rb") (ert-deftest ruby--test-chained-indentation () (with-temp-buffer commit b9e813f79f2d7afb5f14caad17a865e66af17f15 Author: Dmitry Gutov Date: Mon Dec 19 19:37:44 2022 +0200 ; ruby-indent-level: Improve the docstring diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index fa51597697f..d7efe982870 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -212,7 +212,7 @@ ruby-indent-tabs-mode :safe 'booleanp) (defcustom ruby-indent-level 2 - "Indentation of Ruby statements." + "Number of spaces for each indentation step in `ruby-mode'." :type 'integer :safe 'integerp) commit 399433cc2b9500b7ee78503c03cead106b76bbd6 Author: Juri Linkov Date: Mon Dec 19 19:54:08 2022 +0200 * lisp/progmodes/project.el: Filter out empty strings from history (bug#58447) (project--read-file-cpd-relative): Do not include empty strings (when prefix has the same length as the string). diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 559da6dd649..605636d93e3 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1045,6 +1045,7 @@ project--read-file-cpd-relative (mapcan (lambda (s) (and (string-prefix-p abbr-cpd s) + (not (eq (length abbr-cpd) (length s))) (list (substring s (length abbr-cpd))))) (symbol-value hist)))) (project--completing-read-strict prompt commit 23f7c9c2a92e4619b7c4d2286d4249f812cd695d Author: Eli Zaretskii Date: Mon Dec 19 19:01:04 2022 +0200 Fix storing email into nnmail by Gnus * lisp/gnus/nnml.el (nnml--encode-headers): Wrap 'rfc2047-encode-string' calls with 'ignore-errors', to avoid disrupting email workflows due to possibly-invalid headers. Reported by Florian Weimer . diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el index 40e4b9ea828..7aa445e6646 100644 --- a/lisp/gnus/nnml.el +++ b/lisp/gnus/nnml.el @@ -776,17 +776,22 @@ nnml-parse-head (nnml--encode-headers headers) headers)))) +;; RFC2047-encode Subject and From, but leave invalid headers unencoded. (defun nnml--encode-headers (headers) (let ((subject (mail-header-subject headers)) (rfc2047-encoding-type 'mime)) (unless (string-match "\\`[[:ascii:]]*\\'" subject) - (setf (mail-header-subject headers) - (mail-encode-encoded-word-string subject t)))) + (let ((encoded-subject + (ignore-errors (mail-encode-encoded-word-string subject t)))) + (if encoded-subject + (setf (mail-header-subject headers) encoded-subject))))) (let ((from (mail-header-from headers)) (rfc2047-encoding-type 'address-mime)) (unless (string-match "\\`[[:ascii:]]*\\'" from) - (setf (mail-header-from headers) - (rfc2047-encode-string from t))))) + (let ((encoded-from + (ignore-errors (rfc2047-encode-string from t)))) + (if encoded-from + (setf (mail-header-from headers) encoded-from)))))) (defun nnml-get-nov-buffer (group &optional incrementalp) (let ((buffer (gnus-get-buffer-create commit 63cdbd986bb8f841717e2d813df6f75b6b02cf8b Author: F. Jason Park Date: Sun Dec 11 19:16:07 2022 -0800 ; Really respect browse-url var in erc-compat * lisp/erc/erc-compat.el: Do what was supposed to be done by 75f26646d4a569cfb485de4baddcda66ff44b2c3 "; Be nicer when updating browse-url var in erc-compat". This is the less harmful version of that patch (from bug#59976#8) but without the cl-lib requirement since users may not want to load the main ERC library right away. * lisp/erc/erc.el: Clarify some comments regarding the core API. diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 77625398abd..fdcb146d42a 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -391,11 +391,11 @@ erc-compat--29-browse-url-irc (cond ((fboundp 'browse-url-irc)) ; 29 ((boundp 'browse-url-default-handlers) ; 28 - (setf (alist-get "\\`irc6?s?://" browse-url-default-handlers - nil nil (lambda (a _) - (and (stringp a) - (string-match-p a "irc://localhost")))) - #'erc-compat--29-browse-url-irc)) + (add-to-list 'browse-url-default-handlers + '("\\`irc6?s?://" . erc-compat--29-browse-url-irc) + nil (lambda (_ a) + (and (stringp (car-safe a)) + (string-match-p (car a) "irc://localhost"))))) ((boundp 'browse-url-browser-function) ; 27 (require 'browse-url) (let ((existing browse-url-browser-function)) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 6cfc39c4bda..6a5e0018964 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1765,8 +1765,7 @@ erc-buffer-list-with-nick ;; to, it was never realized. ;; ;; New library code should use the `erc--target' struct instead. -;; Third-party code can continue to use this until a getter for -;; `erc--target' (or whatever replaces it) is exported. +;; Third-party code can continue to use this and `erc-default-target'. (defvar-local erc-default-recipients nil "List of default recipients of the current buffer.") @@ -6012,13 +6011,14 @@ erc--current-buffer-joined-p ;; While `erc-default-target' happens to return nil in channel buffers ;; you've parted or from which you've been kicked, using it to detect ;; whether a channel is currently joined may become unreliable in the -;; future. For now, new code should consider using +;; future. For now, third-party code can use ;; ;; (erc-get-channel-user (erc-current-nick)) ;; -;; and expect a nicer option eventually. For retrieving a target -;; regardless of subscription or connection status, use replacements -;; based on `erc--target' instead. See also `erc--default-target'. +;; A predicate may be provided eventually. For retrieving a target's +;; name regardless of subscription or connection status, new library +;; code should use `erc--default-target'. Third-party code should +;; continue to use `erc-default-target'. (defun erc-default-target () "Return the current default target (as a character string) or nil if none." commit 64163618d21bfa31e56b47c813ce50681c3d3556 Author: Richard Hansen Date: Sun Dec 18 23:04:00 2022 -0500 whitespace: Fix unintended change in buffer modification status * lisp/whitespace.el (whitespace--empty-at-bob-matcher) whitespace--empty-at-eob-matcher, whitespace--update-bob-eob): Silently add the `font-lock-multiline' text property when highlighting beginning-of-buffer and end-of-buffer empty lines to prevent Emacs from running modification hooks or considering the buffer to be modified (Bug#60066). * test/lisp/whitespace-tests.el (whitespace-tests--empty-bob-eob-modified): Add a regression test. diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 25ea07e9db7..9bc6ad9db46 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -2268,10 +2268,11 @@ whitespace--empty-at-bob-matcher (save-excursion (goto-char whitespace-point) (line-beginning-position))))) (when (= p 1) - ;; See the comment in `whitespace--update-bob-eob' for why this - ;; text property is added here. - (put-text-property 1 whitespace-bob-marker - 'font-lock-multiline t)) + (with-silent-modifications + ;; See the comment in `whitespace--update-bob-eob' for why + ;; this text property is added here. + (put-text-property 1 whitespace-bob-marker + 'font-lock-multiline t))) (when (< p e) (set-match-data (list p e)) (goto-char e)))) @@ -2292,10 +2293,11 @@ whitespace--empty-at-eob-matcher empty lines will no longer be EoB empty lines. Highlighting those lines can be distracting.)" (when (= limit (1+ (buffer-size))) - ;; See the comment in `whitespace--update-bob-eob' for why this - ;; text property is added here. - (put-text-property whitespace-eob-marker limit - 'font-lock-multiline t)) + (with-silent-modifications + ;; See the comment in `whitespace--update-bob-eob' for why this + ;; text property is added here. + (put-text-property whitespace-eob-marker limit + 'font-lock-multiline t))) (let ((b (max (point) whitespace-eob-marker whitespace-bob-marker ; See comment in the bob func. (save-excursion (goto-char whitespace-point) @@ -2437,8 +2439,9 @@ whitespace--update-bob-eob (save-match-data (when (looking-at whitespace-empty-at-bob-regexp) (set-marker whitespace-bob-marker (match-end 1)) - (put-text-property (match-beginning 1) (match-end 1) - 'font-lock-multiline t)))) + (with-silent-modifications + (put-text-property (match-beginning 1) (match-end 1) + 'font-lock-multiline t))))) (when (or (null end) (>= end (save-excursion (goto-char whitespace-eob-marker) @@ -2451,8 +2454,9 @@ whitespace--update-bob-eob (when (whitespace--looking-back whitespace-empty-at-eob-regexp) (set-marker whitespace-eob-marker (match-beginning 1)) - (put-text-property (match-beginning 1) (match-end 1) - 'font-lock-multiline t))))))))) + (with-silent-modifications + (put-text-property (match-beginning 1) (match-end 1) + 'font-lock-multiline t)))))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/test/lisp/whitespace-tests.el b/test/lisp/whitespace-tests.el index fb53543c9e1..3e94d7e921b 100644 --- a/test/lisp/whitespace-tests.el +++ b/test/lisp/whitespace-tests.el @@ -327,6 +327,16 @@ whitespace-tests--empty-bob-eob-read-only-buffer "«:whitespace-empty:\n" "»"))))) +(ert-deftest whitespace-tests--empty-bob-eob-modified () + "Regression test for Bug#60066." + (whitespace-tests--with-test-buffer '() + (insert "\nx\n\n") + (goto-char 2) + (set-buffer-modified-p nil) + (let ((whitespace-style '(face empty))) + (whitespace-mode 1) + (should (not (buffer-modified-p)))))) + (provide 'whitespace-tests) ;;; whitespace-tests.el ends here commit a75d1da911c07a201a19d8827cd74f181220c274 Author: Eli Zaretskii Date: Mon Dec 19 15:33:09 2022 +0200 Make emacsclient add abbreviated file names to file-name-history * lisp/server.el (server-visit-files): Use 'file-name-history--add' to add the visited files to history. (Bug#60097) diff --git a/lisp/server.el b/lisp/server.el index fd740d126df..d963ee5b1e0 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1495,7 +1495,7 @@ server-visit-files minibuffer-auto-raise)) (filen (car file)) (obuf (get-file-buffer filen))) - (add-to-history 'file-name-history filen) + (file-name-history--add filen) (if (null obuf) (progn (run-hooks 'pre-command-hook) commit b3e7768a0ee0e894d7a4c232842af8be014ff8cb Author: Mattias Engdegård Date: Mon Dec 19 12:05:09 2022 +0100 Repair setopt test after error demotion to warning * test/lisp/cus-edit-tests.el (test-setopt): Check for a warrning instead of an error in attempt to call `setopt` with a value that does not match the declared type (bug#60162). diff --git a/test/lisp/cus-edit-tests.el b/test/lisp/cus-edit-tests.el index 0ef5168109b..31ba68b4107 100644 --- a/test/lisp/cus-edit-tests.el +++ b/test/lisp/cus-edit-tests.el @@ -83,7 +83,14 @@ cus-edit-test-foo1 (ert-deftest test-setopt () (should (= (setopt cus-edit-test-foo1 1) 1)) (should (= cus-edit-test-foo1 1)) - (should-error (setopt cus-edit-test-foo1 :foo))) - + (let* ((text-quoting-style 'grave) + (warn-txt + (with-current-buffer (get-buffer-create "*Warnings*") + (let ((inhibit-read-only t)) + (erase-buffer)) + (setopt cus-edit-test-foo1 :foo) + (buffer-substring-no-properties (point-min) (point-max))))) + (should (string-search "Value `:foo' does not match type number" + warn-txt)))) (provide 'cus-edit-tests) ;;; cus-edit-tests.el ends here