commit 9c282faf26eb517532508d466270b7b97d436c70 (HEAD, refs/remotes/origin/master) Author: Stefan Monnier Date: Sat Jul 8 20:19:02 2023 -0400 cl-print.el: Reduce code duplication While at it, fix a bug in `cl-print-object-contents` for strings, where we forgot to pass `stream` to `princ` at one place and simplify a `substring` call using a negative offset. * lisp/emacs-lisp/cl-print.el (cl-print--cons-tail) (cl-print--vector-contents, cl-print--struct-contents) (cl-print--string-props): New functions, extracted from `cl-print-object-contents`. (cl-print-object, cl-print-object-contents): Use them. diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el index 61586526ca1..9578d556421 100644 --- a/lisp/emacs-lisp/cl-print.el +++ b/lisp/emacs-lisp/cl-print.el @@ -66,8 +66,7 @@ cl-print-object (if (and cl-print--depth (natnump print-level) (> cl-print--depth print-level)) (cl-print-insert-ellipsis object 0 stream) - (let ((car (pop object)) - (count 1)) + (let ((car (pop object))) (if (and print-quoted (memq car '(\, quote function \` \,@ \,.)) (consp object) @@ -80,26 +79,12 @@ cl-print-object stream) (cl-print-object (car object) stream)) (princ "(" stream) - (cl-print-object car stream) - (while (and (consp object) - (not (cond - (cl-print--number-table - (numberp (gethash object cl-print--number-table))) - ((memq object cl-print--currently-printing)) - (t (push object cl-print--currently-printing) - nil)))) - (princ " " stream) - (if (or (not (natnump print-length)) (> print-length count)) - (cl-print-object (pop object) stream) - (cl-print-insert-ellipsis object print-length stream) - (setq object nil)) - (cl-incf count)) - (when object - (princ " . " stream) (cl-print-object object stream)) + (cl-print--cons-tail car object stream) (princ ")" stream))))) -(cl-defmethod cl-print-object-contents ((object cons) _start stream) - (let ((count 0)) +(defun cl-print--cons-tail (car object stream) + (let ((count 1)) + (cl-print-object car stream) (while (and (consp object) (not (cond (cl-print--number-table @@ -107,33 +92,27 @@ cl-print-object-contents ((memq object cl-print--currently-printing)) (t (push object cl-print--currently-printing) nil)))) - (unless (zerop count) - (princ " " stream)) + (princ " " stream) (if (or (not (natnump print-length)) (> print-length count)) (cl-print-object (pop object) stream) - (cl-print-insert-ellipsis object print-length stream) + (cl-print-insert-ellipsis object t stream) (setq object nil)) (cl-incf count)) (when object (princ " . " stream) (cl-print-object object stream)))) +(cl-defmethod cl-print-object-contents ((object cons) _start stream) + (cl-print--cons-tail (car object) (cdr object) stream)) + (cl-defmethod cl-print-object ((object vector) stream) (if (and cl-print--depth (natnump print-level) (> cl-print--depth print-level)) (cl-print-insert-ellipsis object 0 stream) (princ "[" stream) - (let* ((len (length object)) - (limit (if (natnump print-length) - (min print-length len) len))) - (dotimes (i limit) - (unless (zerop i) (princ " " stream)) - (cl-print-object (aref object i) stream)) - (when (< limit len) - (princ " " stream) - (cl-print-insert-ellipsis object limit stream))) + (cl-print--vector-contents object 0 stream) (princ "]" stream))) -(cl-defmethod cl-print-object-contents ((object vector) start stream) +(defun cl-print--vector-contents (object start stream) (let* ((len (length object)) (limit (if (natnump print-length) (min (+ start print-length) len) len)) @@ -146,6 +125,9 @@ cl-print-object-contents (princ " " stream) (cl-print-insert-ellipsis object limit stream)))) +(cl-defmethod cl-print-object-contents ((object vector) start stream) + (cl-print--vector-contents object start stream)) ;FIXME: η-redex! + (cl-defmethod cl-print-object ((object hash-table) stream) (princ "# cl-print--depth print-level)) (cl-print-insert-ellipsis object 0 stream) (princ "#s(" stream) - (let* ((class (cl-find-class (type-of object))) - (slots (cl--struct-class-slots class)) - (len (length slots)) - (limit (if (natnump print-length) - (min print-length len) len))) - (princ (cl--struct-class-name class) stream) - (dotimes (i limit) - (let ((slot (aref slots i))) - (princ " :" stream) - (princ (cl--slot-descriptor-name slot) stream) - (princ " " stream) - (cl-print-object (aref object (1+ i)) stream))) - (when (< limit len) - (princ " " stream) - (cl-print-insert-ellipsis object limit stream))) + (princ (cl--struct-class-name (cl-find-class (type-of object))) stream) + (cl-print--struct-contents object 0 stream) (princ ")" stream))) -(cl-defmethod cl-print-object-contents ((object cl-structure-object) start stream) +(defun cl-print--struct-contents (object start stream) (let* ((class (cl-find-class (type-of object))) (slots (cl--struct-class-slots class)) (len (length slots)) @@ -258,7 +227,7 @@ cl-print-object-contents (i start)) (while (< i limit) (let ((slot (aref slots i))) - (unless (= i start) (princ " " stream)) + (unless (and (= i start) (> i 0)) (princ " " stream)) (princ ":" stream) (princ (cl--slot-descriptor-name slot) stream) (princ " " stream) @@ -268,6 +237,9 @@ cl-print-object-contents (princ " " stream) (cl-print-insert-ellipsis object limit stream)))) +(cl-defmethod cl-print-object-contents ((object cl-structure-object) start stream) + (cl-print--struct-contents object start stream)) ;FIXME: η-redex! + (cl-defmethod cl-print-object ((object string) stream) (unless stream (setq stream standard-output)) (let* ((has-properties (or (text-properties-at 0 object) @@ -294,28 +266,36 @@ cl-print-object (- (point) 1) stream))))) ;; Print the property list. (when has-properties - (let* ((interval-limit (and (natnump print-length) - (max 1 (/ print-length 3)))) - (interval-count 0) - (start-pos (if (text-properties-at 0 object) - 0 (next-property-change 0 object))) - (end-pos (next-property-change start-pos object len))) - (while (and (or (null interval-limit) - (< interval-count interval-limit)) - (< start-pos len)) - (let ((props (text-properties-at start-pos object))) - (when props - (princ " " stream) (princ start-pos stream) - (princ " " stream) (princ end-pos stream) - (princ " " stream) (cl-print-object props stream) - (cl-incf interval-count)) - (setq start-pos end-pos - end-pos (next-property-change start-pos object len)))) - (when (< start-pos len) - (princ " " stream) - (cl-print-insert-ellipsis object (list start-pos) stream))) + (cl-print--string-props object 0 stream) (princ ")" stream))))) +(defun cl-print--string-props (object start stream) + (let* ((first (not (eq start 0))) + (len (length object)) + (interval-limit (and (natnump print-length) + (max 1 (/ print-length 3)))) + (interval-count 0) + (start-pos (if (text-properties-at start object) + start (next-property-change start object))) + (end-pos (next-property-change start-pos object len))) + (while (and (or (null interval-limit) + (< interval-count interval-limit)) + (< start-pos len)) + (let ((props (text-properties-at start-pos object))) + (when props + (if first + (setq first nil) + (princ " " stream)) + (princ start-pos stream) + (princ " " stream) (princ end-pos stream) + (princ " " stream) (cl-print-object props stream) + (cl-incf interval-count)) + (setq start-pos end-pos + end-pos (next-property-change start-pos object len)))) + (when (< start-pos len) + (princ " " stream) + (cl-print-insert-ellipsis object (list start-pos) stream)))) + (cl-defmethod cl-print-object-contents ((object string) start stream) ;; If START is an integer, it is an index into the string, and the ;; ellipsis that needs to be expanded is part of the string. If @@ -328,35 +308,13 @@ cl-print-object-contents (min (+ start print-length) len) len)) (substr (substring-no-properties object start limit)) (printed (prin1-to-string substr)) - (trimmed (substring printed 1 (1- (length printed))))) - (princ trimmed) + (trimmed (substring printed 1 -1))) + (princ trimmed stream) (when (< limit len) (cl-print-insert-ellipsis object limit stream))) ;; Print part of the property list. - (let* ((first t) - (interval-limit (and (natnump print-length) - (max 1 (/ print-length 3)))) - (interval-count 0) - (start-pos (car start)) - (end-pos (next-property-change start-pos object len))) - (while (and (or (null interval-limit) - (< interval-count interval-limit)) - (< start-pos len)) - (let ((props (text-properties-at start-pos object))) - (when props - (if first - (setq first nil) - (princ " " stream)) - (princ start-pos stream) - (princ " " stream) (princ end-pos stream) - (princ " " stream) (cl-print-object props stream) - (cl-incf interval-count)) - (setq start-pos end-pos - end-pos (next-property-change start-pos object len)))) - (when (< start-pos len) - (princ " " stream) - (cl-print-insert-ellipsis object (list start-pos) stream)))))) + (cl-print--string-props object (car start) stream)))) ;;; Circularity and sharing. commit afa4fa17232a806907e975c9532bdf12bb3e6c4c Author: Basil L. Contovounesios Date: Sat Jul 8 22:27:20 2023 +0100 ; Re-add recently removed comment in cyrillic.el. https://lists.gnu.org/r/emacs-devel/2023-07/msg00303.html diff --git a/lisp/language/cyrillic.el b/lisp/language/cyrillic.el index cf3ee5a2b9d..2b32304c829 100644 --- a/lisp/language/cyrillic.el +++ b/lisp/language/cyrillic.el @@ -127,7 +127,7 @@ 'koi8-u "KOI8-U 8-bit encoding for Cyrillic (MIME: KOI8-U)" :coding-type 'charset ;; This used to be ?U which collided with UTF-8. - :mnemonic ?У + :mnemonic ?У ; CYRILLIC CAPITAL LETTER U :charset-list '(koi8-u) :mime-charset 'koi8-u) commit e074081af3de6bbdff330f6fa60355b3a86215bb Author: Jim Porter Date: Fri Jul 7 23:18:33 2023 -0700 Add special '$GID' variable in Eshell See bug#64529. * lisp/eshell/esh-var.el (eshell-variable-aliases-list): Add '$GID'. * test/lisp/eshell/esh-var-tests.el (esh-var-test/gid-var): New test. * doc/misc/eshell.texi (Variables): Document '$GID'. * etc/NEWS: Announce this change (and the previous change for '$UID'). diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index 6e92d598387..c6376882542 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi @@ -993,6 +993,13 @@ Variables its value will be @acronym{UID} for the user associated with that remote connection. +@vindex $GID +@item $GID +This returns the effective @acronym{GID} for the current user. Like +@code{$UID}, this variable is connection-aware, so when the current +directory is remote, its value will be @acronym{GID} for the user +associated with that remote connection. + @vindex $_ @item $_ This refers to the last argument of the last command. With a diff --git a/etc/NEWS b/etc/NEWS index 0556e8be585..246e6b21838 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -202,6 +202,11 @@ or get a sublist of elements 2 through 4 with '$my-list[2..5]'. For more information, see the "(eshell) Dollars Expansion" node in the Eshell manual. ++++ +*** Eshell's '$UID' and '$GID' variables are now connection-aware. +Now, when expanding '$UID' or '$GID' in a remote directory, the value +is the user or group ID associated with the remote connection. + --- *** Eshell now uses 'field' properties in its output. In particular, this means that pressing the '' key moves the diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index 7dcaff1e24f..c7c0a21d2a9 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el @@ -163,6 +163,7 @@ eshell-variable-aliases-list ("LINES" ,(lambda () (window-body-height nil 'remap)) t t) ("INSIDE_EMACS" eshell-inside-emacs t) ("UID" ,(lambda () (file-user-uid)) nil t) + ("GID" ,(lambda () (file-group-gid)) nil t) ;; for esh-ext.el ("PATH" (,(lambda () (string-join (eshell-get-path t) (path-separator))) diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index 771bd5a419c..3e58fe749dd 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el @@ -829,6 +829,10 @@ esh-var-test/uid-var "Test that $UID is equivalent to (user-uid) for local directories." (eshell-command-result-equal "echo $UID" (user-uid))) +(ert-deftest esh-var-test/gid-var () + "Test that $GID is equivalent to (group-gid) for local directories." + (eshell-command-result-equal "echo $GID" (group-gid))) + (ert-deftest esh-var-test/last-status-var-lisp-command () "Test using the \"last exit status\" ($?) variable with a Lisp command." (with-temp-eshell commit 8c5fef4eb301d878b9761ebf74f845895f014610 Author: Jim Porter Date: Sat Jul 8 12:13:22 2023 -0700 ; * doc/misc/eshell.texi: Fix last change. diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index 5972d2834b0..6e92d598387 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi @@ -338,7 +338,7 @@ Arguments Inside of double quotes, most characters have no special meaning. However, @samp{\}, @samp{"}, and @samp{$} are still special; to escape them, use backslash as above. Thus, if the value of the variable -@var{answer} is @code{42}, then @code{"The answer is: \"$answer\""} +@var{answer} is @code{42}, then @code{"The answer is: \"$@var{answer}\""} returns the string @code{The answer is: "42"}. However, when escaping characters with no special meaning, the result is the full @code{\@var{c}} sequence. For example, @code{"foo\bar"} means the @@ -2145,12 +2145,12 @@ Extra built-in commands @item ff @cmindex ff Shorthand for the the function @code{find-name-dired} (@pxref{Dired -and Find, , , elisp, The Emacs Lisp Reference Manual}). +and Find, , , emacs, The Emacs Editor}). @item gf @cmindex gf Shorthand for the the function @code{find-grep-dired} (@pxref{Dired -and Find, , , elisp, The Emacs Lisp Reference Manual}). +and Find, , , emacs, The Emacs Editor}). @item intersection @cmindex intersection commit 1b7c9ecc8f55675207d0b38ea4007de3aede9941 Author: Stefan Monnier Date: Sat Jul 8 15:10:23 2023 -0400 pp-fill: Fix missing indentation in some cases * lisp/emacs-lisp/pp.el (pp-fill): Improve handling of char-tables. (pp-buffer): Improve backward compatibility. diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el index 625fc5f252d..550fab2f4b3 100644 --- a/lisp/emacs-lisp/pp.el +++ b/lisp/emacs-lisp/pp.el @@ -177,8 +177,9 @@ pp-fill (< (point) end)) (let ((beg (point)) ;; Whether we're in front of an element with paired delimiters. - ;; Can be something funky like #'(lambda ..) or ,'#s(...). - (paired (when (looking-at "['`,#]*[[:alpha:]]*\\([({[\"]\\)") + ;; Can be something funky like #'(lambda ..) or ,'#s(...) + ;; Or also #^[..]. + (paired (when (looking-at "['`,#]*[[:alpha:]^]*\\([({[\"]\\)") (match-beginning 1)))) ;; Go to the end of the sexp. (goto-char (or (scan-sexps (or paired (point)) 1) end)) @@ -238,7 +239,15 @@ pp-fill (defun pp-buffer () "Prettify the current buffer with printed representation of a Lisp object." (interactive) - (funcall pp-default-function (point-min) (point-max)) + ;; The old code used `indent-sexp' which mostly works "anywhere", + ;; so let's make sure we also work right in buffers that aren't + ;; setup specifically for Lisp. + (if (and (eq (syntax-table) emacs-lisp-mode-syntax-table) + (eq indent-line-function #'lisp-indent-line)) + (funcall pp-default-function (point-min) (point-max)) + (with-syntax-table emacs-lisp-mode-syntax-table + (let ((indent-line-function #'lisp-indent-line)) + (funcall pp-default-function (point-min) (point-max))))) ;; Preserve old behavior of (usually) finishing with a newline and ;; with point at BOB. (goto-char (point-max)) commit d082b26364334416ff24b9ec169817a133a64d02 Author: Stefan Monnier Date: Sat Jul 8 15:08:10 2023 -0400 * lisp/menu-bar.el (menu-bar-search-options-menu): Don't quote lambdas Expose the commands to the compiler. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 21785e43a6e..030fe374598 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -1464,30 +1464,30 @@ menu-bar-search-options-menu (word-search-regexp "Whole Words" "Whole word"))) (bindings--define-key menu (vector (nth 0 x)) `(menu-item ,(nth 1 x) - (lambda () - (interactive) - (setq search-default-mode #',(nth 0 x)) - (message ,(format "%s search enabled" (nth 2 x)))) + ,(lambda () + (interactive) + (setq search-default-mode (nth 0 x)) + (message "%s search enabled" (nth 2 x))) :help ,(format "Enable %s search" (downcase (nth 2 x))) :button (:radio . (eq search-default-mode #',(nth 0 x)))))) (bindings--define-key menu [regexp-search] - '(menu-item "Regular Expression" - (lambda () - (interactive) - (setq search-default-mode t) - (message "Regular-expression search enabled")) + `(menu-item "Regular Expression" + ,(lambda () + (interactive) + (setq search-default-mode t) + (message "Regular-expression search enabled")) :help "Enable regular-expression search" :button (:radio . (eq search-default-mode t)))) (bindings--define-key menu [regular-search] - '(menu-item "Literal Search" - (lambda () - (interactive) - (when search-default-mode - (setq search-default-mode nil) - (when (symbolp search-default-mode) - (message "Literal search enabled")))) + `(menu-item "Literal Search" + ,(lambda () + (interactive) + (when search-default-mode + (setq search-default-mode nil) + (when (symbolp search-default-mode) + (message "Literal search enabled")))) :help "Disable special search modes" :button (:radio . (not search-default-mode)))) commit 05984303a58c4700f9f57a9d013a5a42e516b537 Author: Basil L. Contovounesios Date: Sat Jul 8 17:50:43 2023 +0100 ; Simplify last change to cyrillic.el. https://lists.gnu.org/r/emacs-devel/2023-07/msg00297.html diff --git a/lisp/language/cyrillic.el b/lisp/language/cyrillic.el index 9ad65877140..cf3ee5a2b9d 100644 --- a/lisp/language/cyrillic.el +++ b/lisp/language/cyrillic.el @@ -127,7 +127,7 @@ 'koi8-u "KOI8-U 8-bit encoding for Cyrillic (MIME: KOI8-U)" :coding-type 'charset ;; This used to be ?U which collided with UTF-8. - :mnemonic ?\u0423 ; ?\N{cyrillic capital letter u} У + :mnemonic ?У :charset-list '(koi8-u) :mime-charset 'koi8-u) commit 44c9293ddd8b335981c2fcac22b1c4b6cf451e2f Author: Vladimir Sedach Date: Mon Jun 26 22:30:25 2023 -0600 ; * test/lisp/shell-tests.el: Add tests for shell-dirtrack-mode (bug#64311) diff --git a/test/lisp/shell-tests.el b/test/lisp/shell-tests.el index db9124e2435..ddddfdb2e0f 100644 --- a/test/lisp/shell-tests.el +++ b/test/lisp/shell-tests.el @@ -64,4 +64,35 @@ shell-tests-split-string (should (equal (split-string-shell-command "ls /tmp/foo\\ bar") '("ls" "/tmp/foo bar"))))) +(ert-deftest shell-dirtrack-on-by-default () + (with-temp-buffer + (shell-mode) + (should shell-dirtrack-mode))) + +(ert-deftest shell-dirtrack-should-not-be-on-in-unrelated-modes () + (with-temp-buffer + (should (not shell-dirtrack-mode)))) + +(ert-deftest shell-dirtrack-sets-list-buffers-directory () + (let ((start-dir default-directory)) + (with-temp-buffer + (should-not list-buffers-directory) + (shell-mode) + (shell-cd "..") + (should list-buffers-directory) + (should (not (equal start-dir list-buffers-directory))) + (should (string-prefix-p list-buffers-directory start-dir))))) + +(ert-deftest shell-directory-tracker-cd () + (let ((start-dir default-directory)) + (with-temp-buffer + (should-not list-buffers-directory) + (shell-mode) + (cl-letf (((symbol-function 'shell-unquote-argument) + (lambda (x) x))) + (shell-directory-tracker "cd ..")) + (should list-buffers-directory) + (should (not (equal start-dir list-buffers-directory))) + (should (string-prefix-p list-buffers-directory start-dir))))) + ;;; shell-tests.el ends here commit 8ffe8422c53e196787c6f404e4cadc7029a7fbd9 Author: Basil L. Contovounesios Date: Sat Jun 3 11:25:05 2023 +0100 Minor tree-sitter cleanups * lisp/treesit.el (treesit-fontify-with-override): Fix docstring grammar. Remove redundant precondition (bug#64052). * src/treesit.c (Ftreesit_parser_set_included_ranges): Fix typo in commentary. (treesit_predicate_equal, treesit_predicate_match) (treesit_predicate_pred): Avoid fixnum roundtrip by using list_length in place of Flength. Make error messages more accurate. (treesit_eval_predicates): Quote predicate names in error message. diff --git a/lisp/treesit.el b/lisp/treesit.el index 9556b315eab..a9761dbb38d 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -894,13 +894,12 @@ treesit-fontify-with-override (start end face override &optional bound-start bound-end) "Apply FACE to the region between START and END. OVERRIDE can be nil, t, `append', `prepend', or `keep'. -See `treesit-font-lock-rules' for their semantic. +See `treesit-font-lock-rules' for their semantics. If BOUND-START and BOUND-END are non-nil, only fontify the region in between them." (when (or (null bound-start) (null bound-end) - (and bound-start bound-end - (<= bound-start end) + (and (<= bound-start end) (>= bound-end start))) (when (and bound-start bound-end) (setq start (max bound-start start) diff --git a/src/treesit.c b/src/treesit.c index d7ccab85908..1f694e47201 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -1649,7 +1649,7 @@ DEFUN ("treesit-parser-set-included-ranges", TSRange *treesit_ranges = xmalloc (sizeof (TSRange) * len); struct buffer *buffer = XBUFFER (XTS_PARSER (parser)->buffer); - /* We can use XFUXNUM, XCAR, XCDR freely because we have checked + /* We can use XFIXNUM, XCAR, XCDR freely because we have checked the input by treesit_check_range_argument. */ for (int idx = 0; !NILP (ranges); idx++, ranges = XCDR (ranges)) @@ -2546,10 +2546,10 @@ treesit_predicate_capture_name_to_text (Lisp_Object name, treesit_predicate_equal (Lisp_Object args, struct capture_range captures, Lisp_Object *signal_data) { - if (XFIXNUM (Flength (args)) != 2) + if (list_length (args) != 2) { *signal_data = list2 (build_string ("Predicate `equal' requires " - "two arguments but only given"), + "two arguments but got"), Flength (args)); return false; } @@ -2581,10 +2581,10 @@ treesit_predicate_equal (Lisp_Object args, struct capture_range captures, treesit_predicate_match (Lisp_Object args, struct capture_range captures, Lisp_Object *signal_data) { - if (XFIXNUM (Flength (args)) != 2) + if (list_length (args) != 2) { *signal_data = list2 (build_string ("Predicate `match' requires two " - "arguments but only given"), + "arguments but got"), Flength (args)); return false; } @@ -2646,11 +2646,11 @@ treesit_predicate_match (Lisp_Object args, struct capture_range captures, treesit_predicate_pred (Lisp_Object args, struct capture_range captures, Lisp_Object *signal_data) { - if (XFIXNUM (Flength (args)) < 2) + if (list_length (args) < 2) { *signal_data = list2 (build_string ("Predicate `pred' requires " "at least two arguments, " - "but was only given"), + "but only got"), Flength (args)); return false; } @@ -2671,7 +2671,7 @@ treesit_predicate_pred (Lisp_Object args, struct capture_range captures, return !NILP (CALLN (Fapply, fn, nodes)); } -/* If all predicates in PREDICATES passes, return true; otherwise +/* If all predicates in PREDICATES pass, return true; otherwise return false. If everything goes fine, don't touch SIGNAL_DATA; if error occurs, set it to a suitable signal data. */ static bool @@ -2696,7 +2696,7 @@ treesit_eval_predicates (struct capture_range captures, Lisp_Object predicates, { *signal_data = list3 (build_string ("Invalid predicate"), fn, build_string ("Currently Emacs only supports" - " equal, match, and pred" + " `equal', `match', and `pred'" " predicates")); pass = false; } commit ac57358762b42a7f0d7f70ce55ed0e7c4b540d16 Author: Basil L. Contovounesios Date: Sat Jun 3 14:46:19 2023 +0100 Minor search_buffer cleanup * src/search.c: Move commentary that used to precede search_buffer to that location once more. Update it for the current arglist. (search_command, search_buffer_non_re, search_buffer): * src/lisp.h (search_buffer): Turn RE flag/argument from an int into a bool. All callers changed (bug#64049). diff --git a/src/lisp.h b/src/lisp.h index b18d0a69786..99f6858c281 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4806,7 +4806,7 @@ fast_c_string_match_ignore_case (Lisp_Object regexp, ptrdiff_t, ptrdiff_t *); extern EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, EMACS_INT, - int, Lisp_Object, Lisp_Object, bool); + bool, Lisp_Object, Lisp_Object, bool); extern void syms_of_search (void); extern void clear_regexp_cache (void); diff --git a/src/search.c b/src/search.c index 0bb52c03eef..122d6166637 100644 --- a/src/search.c +++ b/src/search.c @@ -1027,7 +1027,7 @@ find_before_next_newline (ptrdiff_t from, ptrdiff_t to, static Lisp_Object search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, - Lisp_Object count, int direction, int RE, bool posix) + Lisp_Object count, int direction, bool RE, bool posix) { EMACS_INT np; EMACS_INT lim; @@ -1130,21 +1130,6 @@ trivial_regexp_p (Lisp_Object regexp) return 1; } -/* Search for the n'th occurrence of STRING in the current buffer, - starting at position POS and stopping at position LIM, - treating STRING as a literal string if RE is false or as - a regular expression if RE is true. - - If N is positive, searching is forward and LIM must be greater than POS. - If N is negative, searching is backward and LIM must be less than POS. - - Returns -x if x occurrences remain to be found (x > 0), - or else the position at the beginning of the Nth occurrence - (if searching backward) or the end (if searching forward). - - POSIX is nonzero if we want full backtracking (POSIX style) - for this pattern. 0 means backtrack only enough to get a valid match. */ - #define TRANSLATE(out, trt, d) \ do \ { \ @@ -1308,7 +1293,7 @@ search_buffer_re (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, static EMACS_INT search_buffer_non_re (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t lim, ptrdiff_t lim_byte, - EMACS_INT n, int RE, Lisp_Object trt, Lisp_Object inverse_trt, + EMACS_INT n, bool RE, Lisp_Object trt, Lisp_Object inverse_trt, bool posix) { unsigned char *raw_pattern, *pat; @@ -1507,10 +1492,28 @@ search_buffer_non_re (Lisp_Object string, ptrdiff_t pos, return result; } +/* Search for the Nth occurrence of STRING in the current buffer, + from buffer position POS/POS_BYTE until LIM/LIM_BYTE. + + If RE, look for matches against the regular expression STRING instead; + if POSIX, enable POSIX style backtracking within that regular + expression. + + If N is positive, search forward; in this case, LIM must be greater + than POS. + + If N is negative, search backward; LIM must be less than POS. + + Return -X if there are X remaining occurrences or matches, + or else the position at the beginning (if N is negative) or the end + (if N is positive) of the Nth occurrence or match against STRING. + + Use TRT and INVERSE_TRT as character translation tables. */ + EMACS_INT search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n, - int RE, Lisp_Object trt, Lisp_Object inverse_trt, bool posix) + bool RE, Lisp_Object trt, Lisp_Object inverse_trt, bool posix) { if (running_asynch_code) save_search_regs (); @@ -2219,7 +2222,7 @@ DEFUN ("search-backward", Fsearch_backward, Ssearch_backward, 1, 4, See also the functions `match-beginning', `match-end' and `replace-match'. */) (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (string, bound, noerror, count, -1, 0, 0); + return search_command (string, bound, noerror, count, -1, false, false); } DEFUN ("search-forward", Fsearch_forward, Ssearch_forward, 1, 4, "MSearch: ", @@ -2244,7 +2247,7 @@ DEFUN ("search-forward", Fsearch_forward, Ssearch_forward, 1, 4, "MSearch: ", See also the functions `match-beginning', `match-end' and `replace-match'. */) (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (string, bound, noerror, count, 1, 0, 0); + return search_command (string, bound, noerror, count, 1, false, false); } DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, @@ -2260,7 +2263,7 @@ DEFUN ("re-search-backward", Fre_search_backward, Sre_search_backward, 1, 4, anchor `(elisp) re-search-backward' for details. */) (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (regexp, bound, noerror, count, -1, 1, 0); + return search_command (regexp, bound, noerror, count, -1, true, false); } DEFUN ("re-search-forward", Fre_search_forward, Sre_search_forward, 1, 4, @@ -2291,7 +2294,7 @@ DEFUN ("re-search-forward", Fre_search_forward, Sre_search_forward, 1, 4, and `replace-match'. */) (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (regexp, bound, noerror, count, 1, 1, 0); + return search_command (regexp, bound, noerror, count, 1, true, false); } DEFUN ("posix-search-backward", Fposix_search_backward, Sposix_search_backward, 1, 4, @@ -2319,7 +2322,7 @@ DEFUN ("posix-search-backward", Fposix_search_backward, Sposix_search_backward, and `replace-match'. */) (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (regexp, bound, noerror, count, -1, 1, 1); + return search_command (regexp, bound, noerror, count, -1, true, true); } DEFUN ("posix-search-forward", Fposix_search_forward, Sposix_search_forward, 1, 4, @@ -2347,7 +2350,7 @@ DEFUN ("posix-search-forward", Fposix_search_forward, Sposix_search_forward, 1, and `replace-match'. */) (Lisp_Object regexp, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count) { - return search_command (regexp, bound, noerror, count, 1, 1, 1); + return search_command (regexp, bound, noerror, count, 1, true, true); } DEFUN ("replace-match", Freplace_match, Sreplace_match, 1, 5, 0, diff --git a/src/treesit.c b/src/treesit.c index 87aa1eeb377..d7ccab85908 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -2628,7 +2628,7 @@ treesit_predicate_match (Lisp_Object args, struct capture_range captures, ZV_BYTE = end_byte; ptrdiff_t val = search_buffer (regexp, start_pos, start_byte, - end_pos, end_byte, 1, 1, Qnil, Qnil, false); + end_pos, end_byte, 1, true, Qnil, Qnil, false); BEGV = old_begv; BEGV_BYTE = old_begv_byte; commit 1a9d454ebf661eb15ef3597c9c17dc59b9c63ee2 Author: Basil L. Contovounesios Date: Sat Jul 8 16:24:15 2023 +0100 ; Fix last change to lisp/language/cyrillic.el. For discussion, see the following emacs-devel thread: https://lists.gnu.org/r/emacs-devel/2023-07/msg00221.html diff --git a/lisp/language/cyrillic.el b/lisp/language/cyrillic.el index f923c84e221..9ad65877140 100644 --- a/lisp/language/cyrillic.el +++ b/lisp/language/cyrillic.el @@ -127,7 +127,7 @@ 'koi8-u "KOI8-U 8-bit encoding for Cyrillic (MIME: KOI8-U)" :coding-type 'charset ;; This used to be ?U which collided with UTF-8. - :mnemonic ?\N{cyrillic capital letter u} ; У + :mnemonic ?\u0423 ; ?\N{cyrillic capital letter u} У :charset-list '(koi8-u) :mime-charset 'koi8-u) commit eedb7111185569e426726fe15242f8ba08f89b31 Author: Michael Albinus Date: Sat Jul 8 16:48:20 2023 +0200 Rearrange setting date and modes in Tramp * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file): Set date and modes if appropriate. (tramp-do-copy-or-rename-file-via-buffer) (tramp-do-copy-or-rename-file-directly) (tramp-do-copy-or-rename-file-out-of-band): Do not set date and modes. diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index d8231bd5bd2..f2cbb74acd2 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1966,7 +1966,11 @@ tramp-do-copy-or-rename-file (t2 (tramp-tramp-file-p newname)) (length (file-attribute-size (file-attributes (file-truename filename)))) - (msg-operation (if (eq op 'copy) "Copying" "Renaming"))) + (file-times (file-attribute-modification-time + (file-attributes filename))) + (file-modes (tramp-default-file-modes filename)) + (msg-operation (if (eq op 'copy) "Copying" "Renaming")) + copy-keep-date) (with-parsed-tramp-file-name (if t1 filename newname) nil (unless length @@ -1991,6 +1995,8 @@ tramp-do-copy-or-rename-file ;; both files, we invoke `cp' or `mv' on the remote ;; host directly. ((tramp-equal-remote filename newname) + (setq copy-keep-date + (or (eq op 'rename) keep-date preserve-uid-gid)) (tramp-do-copy-or-rename-file-directly op filename newname ok-if-already-exists keep-date preserve-uid-gid)) @@ -1999,6 +2005,8 @@ tramp-do-copy-or-rename-file ((and (tramp-method-out-of-band-p v1 length) (tramp-method-out-of-band-p v2 length)) + (setq copy-keep-date + (tramp-get-method-parameter v 'tramp-copy-keep-date)) (tramp-do-copy-or-rename-file-out-of-band op filename newname ok-if-already-exists keep-date)) @@ -2020,6 +2028,8 @@ tramp-do-copy-or-rename-file (cond ;; Fast track on local machine. ((tramp-local-host-p v) + (setq copy-keep-date + (or (eq op 'rename) keep-date preserve-uid-gid)) (tramp-do-copy-or-rename-file-directly op filename newname ok-if-already-exists keep-date preserve-uid-gid)) @@ -2027,6 +2037,8 @@ tramp-do-copy-or-rename-file ;; If the Tramp file has an out-of-band method, the ;; corresponding copy-program can be invoked. ((tramp-method-out-of-band-p v length) + (setq copy-keep-date + (tramp-get-method-parameter v 'tramp-copy-keep-date)) (tramp-do-copy-or-rename-file-out-of-band op filename newname ok-if-already-exists keep-date)) @@ -2054,10 +2066,19 @@ tramp-do-copy-or-rename-file ;; When newname did exist, we have wrong cached values. (when t2 (with-parsed-tramp-file-name newname v2 - (tramp-flush-file-properties v2 v2-localname))))))))) + (tramp-flush-file-properties v2 v2-localname))) + + ;; KEEP-DATE handling. + (when (and keep-date (not copy-keep-date)) + (tramp-compat-set-file-times + newname file-times (unless ok-if-already-exists 'nofollow))) + + ;; Set the mode. + (unless (and keep-date copy-keep-date) + (set-file-modes newname file-modes)))))))) (defun tramp-do-copy-or-rename-file-via-buffer - (op filename newname ok-if-already-exists keep-date) + (op filename newname _ok-if-already-exists _keep-date) "Use an Emacs buffer to copy or rename a file. First arg OP is either `copy' or `rename' and indicates the operation. FILENAME is the source file, NEWNAME the target file. @@ -2084,14 +2105,7 @@ tramp-do-copy-or-rename-file-via-buffer (with-temp-file newname (set-buffer-multibyte nil) (insert-file-contents-literally filename))) - ;; KEEP-DATE handling. - (when keep-date - (tramp-compat-set-file-times - newname - (file-attribute-modification-time (file-attributes filename)) - (unless ok-if-already-exists 'nofollow))) - ;; Set the mode. - (set-file-modes newname (tramp-default-file-modes filename)) + ;; If the operation was `rename', delete the original file. (unless (eq op 'copy) (delete-file filename))) @@ -2107,12 +2121,10 @@ tramp-do-copy-or-rename-file-directly the uid and gid from FILENAME." ;; FILENAME and NEWNAME are already expanded. (let ((t1 (tramp-tramp-file-p filename)) - (t2 (tramp-tramp-file-p newname)) - (file-times (file-attribute-modification-time - (file-attributes filename))) - (file-modes (tramp-default-file-modes filename))) + (t2 (tramp-tramp-file-p newname))) (with-parsed-tramp-file-name (if t1 filename newname) nil - (let* ((cmd (cond ((and (eq op 'copy) preserve-uid-gid) "cp -f -p") + (let* ((cmd (cond ((and (eq op 'copy) (or keep-date preserve-uid-gid)) + "cp -f -p") ((eq op 'copy) "cp -f") ((eq op 'rename) "mv -f") (t (tramp-error @@ -2241,14 +2253,7 @@ tramp-do-copy-or-rename-file-directly (list tmpfile localname2 ok-if-already-exists))))) ;; Save exit. - (ignore-errors (delete-file tmpfile))))))))) - - ;; Set the time and mode. Mask possible errors. - (ignore-errors - (when keep-date - (tramp-compat-set-file-times - newname file-times (unless ok-if-already-exists 'nofollow)) - (set-file-modes newname file-modes)))))) + (ignore-errors (delete-file tmpfile)))))))))))) (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname ok-if-already-exists keep-date) @@ -2260,7 +2265,7 @@ tramp-do-copy-or-rename-file-out-of-band (v2 (and (tramp-tramp-file-p newname) (tramp-dissect-file-name newname))) (v (or v1 v2)) - copy-program copy-args copy-env copy-keep-date listener spec + copy-program copy-args copy-env listener spec options source target remote-copy-program remote-copy-args p) (if (and v1 v2 (string-empty-p (tramp-scp-direct-remote-copying v1 v2))) @@ -2332,8 +2337,6 @@ tramp-do-copy-or-rename-file-out-of-band ?y (tramp-scp-force-scp-protocol v) ?z (tramp-scp-direct-remote-copying v1 v2)) copy-program (tramp-get-method-parameter v 'tramp-copy-program) - copy-keep-date (tramp-get-method-parameter - v 'tramp-copy-keep-date) copy-args ;; " " has either been a replacement of "%k" (when ;; keep-date argument is non-nil), or a replacement for @@ -2441,19 +2444,7 @@ tramp-do-copy-or-rename-file-out-of-band ;; Houston, we have a problem! Likely, the listener is ;; still running, so let's clear everything (but the ;; cached password). - (tramp-cleanup-connection v 'keep-debug 'keep-password)))) - - ;; Handle KEEP-DATE argument. - (when (and keep-date (not copy-keep-date)) - (tramp-compat-set-file-times - newname - (file-attribute-modification-time (file-attributes filename)) - (unless ok-if-already-exists 'nofollow))) - - ;; Set the mode. - (unless (and keep-date copy-keep-date) - (ignore-errors - (set-file-modes newname (tramp-default-file-modes filename))))) + (tramp-cleanup-connection v 'keep-debug 'keep-password))))) ;; If the operation was `rename', delete the original file. (unless (eq op 'copy) commit 0a35c991c19a6dd0a707f2baa868f8989242c3ab Merge: 567258ab430 4c2cc21354a Author: Eli Zaretskii Date: Sat Jul 8 16:43:37 2023 +0300 Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs commit 4c2cc21354a500b0fc48994b7b60648ef5f00a2d Author: Basil L. Contovounesios Date: Mon Jul 3 10:10:47 2023 +0100 Fix condition-case-unless-debug with :success * lisp/subr.el (condition-case-unless-debug): Don't add debug condition to :success handler (bug#64404). * test/lisp/subr-tests.el (condition-case-unless-debug) (condition-case-unless-debug-success): New tests. diff --git a/lisp/subr.el b/lisp/subr.el index 4c462830120..483083b29c3 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4987,9 +4987,12 @@ condition-case-unless-debug `(condition-case ,var ,bodyform ,@(mapcar (lambda (handler) - `((debug ,@(if (listp (car handler)) (car handler) - (list (car handler)))) - ,@(cdr handler))) + (let ((condition (car handler))) + (if (eq condition :success) + handler + `((debug ,@(if (listp condition) condition + (list condition))) + ,@(cdr handler))))) handlers))) (defmacro with-demoted-errors (format &rest body) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 1c220b1da18..0d409cead26 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -1256,5 +1256,36 @@ subr--copy-tree "((a b) (a b) #2# #2# #3# #3#)" "((a b) (a b) [c d] [c d] #s(e f) #s(e f))"))))))) +(ert-deftest condition-case-unless-debug () + "Test `condition-case-unless-debug'." + (let ((debug-on-error nil)) + (with-suppressed-warnings ((suspicious condition-case)) + (should (= 0 (condition-case-unless-debug nil 0)))) + (should (= 0 (condition-case-unless-debug nil 0 (t 1)))) + (should (= 0 (condition-case-unless-debug x 0 (t (1+ x))))) + (should (= 1 (condition-case-unless-debug nil (error "") (t 1)))) + (should (equal (condition-case-unless-debug x (error "") (t x)) + '(error ""))))) + +(ert-deftest condition-case-unless-debug-success () + "Test `condition-case-unless-debug' with :success (bug#64404)." + (let ((debug-on-error nil)) + (should (= 1 (condition-case-unless-debug nil 0 (:success 1)))) + (should (= 1 (condition-case-unless-debug nil 0 (:success 1) (t 2)))) + (should (= 1 (condition-case-unless-debug nil 0 (t 2) (:success 1)))) + (should (= 1 (condition-case-unless-debug x 0 (:success (1+ x))))) + (should (= 1 (condition-case-unless-debug x 0 (:success (1+ x)) (t x)))) + (should (= 1 (condition-case-unless-debug x 0 (t x) (:success (1+ x))))) + (should (= 2 (condition-case-unless-debug nil (error "") + (:success 1) (t 2)))) + (should (= 2 (condition-case-unless-debug nil (error "") + (t 2) (:success 1)))) + (should (equal (condition-case-unless-debug x (error "") + (:success (1+ x)) (t x)) + '(error ""))) + (should (equal (condition-case-unless-debug x (error "") + (t x) (:success (1+ x))) + '(error ""))))) + (provide 'subr-tests) ;;; subr-tests.el ends here commit 567258ab4309a7406cd4087d28cd0e820b17e157 Author: Spencer Baugh Date: Mon Jul 3 09:59:04 2023 -0400 Mention minibuffer-next-completion in completion-help Now that it's not necessary to switch to the *Completions* buffer to switch between and choose completions, we should make that clear in the help text. Let's also make the bindings uniform both in and outside the *Completions* buffer so users don't have to think about the difference. In working with new users, they've assumed that since the help text in *Completions* says "Click on a completion to select it", that that's the only way to select a completion. This text should help clarify that. * doc/emacs/mini.texi (Completion Commands): Document new bindings. * lisp/simple.el (completion-list-mode-map): Bind minibuffer-{next,previous,choose}-completion. (completion-setup-function): Mention bindings for minibuffer-{next,previous,choose}-completion. (Bug#64425) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 87546aadfde..21e2d38e96f 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -391,7 +391,7 @@ Completion Commands @findex minibuffer-choose-completion @item M-@key{DOWN} @itemx M-@key{UP} -While in the minibuffer, @kbd{M-@key{DOWN}} +While in the minibuffer or in the completion list buffer, @kbd{M-@key{DOWN}} (@code{minibuffer-next-completion} and @kbd{M-@key{UP}} (@code{minibuffer-previous-completion}) navigate through the completions and displayed in the completions buffer. When @@ -411,7 +411,7 @@ Completion Commands @itemx @key{prior} Typing @kbd{M-v}, while in the minibuffer, selects the window showing the completion list (@code{switch-to-completions}). This paves the -way for using the commands below. @key{PageUp}, @key{prior} and +way for also using the commands below. @key{PageUp}, @key{prior} and @kbd{M-g M-c} does the same. You can also select the window in other ways (@pxref{Windows}). diff --git a/lisp/simple.el b/lisp/simple.el index 7da2bf0fae2..e31ef026ad5 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9804,6 +9804,9 @@ completion-list-mode-map (define-key map [right] 'next-completion) (define-key map [?\t] 'next-completion) (define-key map [backtab] 'previous-completion) + (define-key map [M-up] 'minibuffer-previous-completion) + (define-key map [M-down] 'minibuffer-next-completion) + (define-key map "\M-\r" 'minibuffer-choose-completion) (define-key map "z" 'kill-current-buffer) (define-key map "n" 'next-completion) (define-key map "p" 'previous-completion) @@ -10198,11 +10201,13 @@ completion-setup-function ;; Maybe insert help string. (when completion-show-help (goto-char (point-min)) - (if (display-mouse-p) - (insert "Click on a completion to select it.\n")) - (insert (substitute-command-keys - "In this buffer, type \\[choose-completion] to \ -select the completion near point.\n\n")))))) + (insert (substitute-command-keys + (if (display-mouse-p) + "Click or type \\[minibuffer-choose-completion] on a completion to select it.\n" + "Type \\[minibuffer-choose-completion] on a completion to select it.\n"))) + (insert (substitute-command-keys + "Type \\[minibuffer-next-completion] or \\[minibuffer-previous-completion] \ +to move point between completions.\n\n")))))) (add-hook 'completion-setup-hook #'completion-setup-function) commit 375dac936fcca902874ecfd1c57b713581641725 Merge: aad13e61dbf 600b90ed568 Author: Eli Zaretskii Date: Sat Jul 8 05:46:10 2023 -0400 Merge from origin/emacs-29 600b90ed568 Mark failing icalendar test as unstable (bug#56241) f8a918c9778 ; * src/coding.c (Fcoding_system_put): Improve doc string. 40f84e906f6 ; * doc/lispref/keymaps.texi (Key Binding Commands): Fix ... 502a7800319 ; Improve documentation of 'vertical-motion' in ELisp manual 0d90873fa41 ; * src/indent.c (Fvertical_motion): Doc fix. 9b38773a20b ; * lisp/dired.el (dired-no-confirm): Doc fix. (Bug#64493) a30ebe7a556 ; Improve documentation of key-binding commands c3fefb2b3ae Improve natnump shortdoc 244d4c837ab correct info documentation of benchmark-call 67def1f5502 * lisp/progmodes/grep.el (rgrep): Fix docstring. 8da2091362d ; Fix documentation of minibuffer-completion commands aa030698cef ; Fix typos in documented names of keymap-* functions a9b46bb25df Include a help-echo for flymake's modeline counters 37ed3d15f38 Avoid errors in completion due to 'completion-regexp-list' 15ff8761777 ; * lisp/register.el (register-val-describe): Doc fix. fe7b909c16c ; Fix two typos in recent changes in the manual 7a74b8c3277 C Mode: Don't fontify foo globally as type due to "struct... 823bf6bdb1a * lisp/rect.el (rectangle--duplicate-right): Fix rectangl... e339d0080d3 ; * test/lisp/misc-tests.el (ert): require misc to avoid ... # Conflicts: # lisp/rect.el commit aad13e61dbf949ca6dea1ff492baca82f40a5738 Author: Martin Rudalics Date: Fri Jul 7 15:56:22 2023 +0200 Fix 'toggle-side-windows' with 3 or more side windows * lisp/window.el (window--state-put-1): Consider 'window-combined-p' when determining 'window-combination-limit'. (window-state-put): Bind 'window-combination-limit' and 'window-combination-resize' to nil. (Bug#64405) diff --git a/lisp/window.el b/lisp/window.el index 5964fe37ee6..424f1319ab7 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -6178,7 +6178,14 @@ window--state-put-1 (let* ((horizontal (eq type 'hc)) (total (window-size window horizontal pixelwise)) (first t) - (window-combination-limit (cdr (assq 'combination-limit state))) + ;; Make sure to make a new parent window for a horizontal + ;; or vertical combination embedded in one of the same type + ;; (see Bug#50867 and Bug#64405). + (window-combination-limit + (and (or (eq (cdr (assq 'combination-limit state)) t) + (and horizontal (window-combined-p window t)) + (and (not horizontal) (window-combined-p window))) + t)) size new) (dolist (item state) ;; Find the next child window. WINDOW always points to the @@ -6418,7 +6425,10 @@ window-state-put head))) (min-width (cdr (assq (if pixelwise 'min-pixel-width 'min-weight) - head)))) + head))) + ;; Bind the following two variables. `window--state-put-1' has + ;; to fully control them (see Bug#50867 and Bug#64405). + window-combination-limit window-combination-resize) (if (and (not totals) (or (> min-height (window-size window nil pixelwise)) (> min-width (window-size window t pixelwise))) commit a19beb4ad43fe8225d384fc64e2406b7d24621a5 Author: Eli Zaretskii Date: Sat Jul 8 11:48:12 2023 +0300 ; Fix last change. diff --git a/etc/NEWS b/etc/NEWS index 52ee07dc54b..0556e8be585 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -557,7 +557,7 @@ operator character following '^' or '\`' becomes literal, but we advise against relying on this. --- -*** Mode-line mnemonics for some coding-systems have changed. +** Mode-line mnemonics for some coding-systems have changed. The mode-line mnemonic for 'utf-7' is now the lowercase 'u', to be consistent with the other encodings of this family. commit bb4b511c4c63762bfd3b96623323a882cc57ecb6 Author: Eli Zaretskii Date: Sat Jul 8 11:47:32 2023 +0300 * etc/NEWS: Document changes to coding-system mnemonics. diff --git a/etc/NEWS b/etc/NEWS index 1a86c9e55e2..52ee07dc54b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -556,6 +556,21 @@ assertion only (which is useless). For historical compatibility, an operator character following '^' or '\`' becomes literal, but we advise against relying on this. +--- +*** Mode-line mnemonics for some coding-systems have changed. +The mode-line mnemonic for 'utf-7' is now the lowercase 'u', to be +consistent with the other encodings of this family. + +The mode-line mnemonic for 'koi8-u' is now 'У', U+0423 CYRILLIC +CAPITAL LETTER U, to distinguish between this encoding and the +UTF-8/UTF-16 family. + +If your terminal cannot display 'У', or if you want to get the old +behavior back for any other reason, you can do that using the +'coding-system-put' function. For example, the following restores the +previous behavior of showing 'U' in the mode line for 'koi8-u': + + (coding-system-put 'koi8-u :mnemonic ?U) * Lisp Changes in Emacs 30.1 commit 6c3e65a75f582ca007a7fbcc4b866680e3b0e626 Author: Ulrich Müller Date: Thu Jul 6 20:36:09 2023 +0200 Disambiguate mode line indication for utf-8 and utf-16 * lisp/international/mule-conf.el (utf-7): * lisp/language/cyrillic.el (koi8-u): Change mnemonic letters to ?u and ?\N{cyrillic capital letter u}, respectively. diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf.el index a27aaf9e522..f65f124b633 100644 --- a/lisp/international/mule-conf.el +++ b/lisp/international/mule-conf.el @@ -1600,7 +1600,7 @@ 'ascii (define-coding-system 'utf-7 "UTF-7 encoding of Unicode (RFC 2152)." :coding-type 'utf-8 - :mnemonic ?U + :mnemonic ?u :mime-charset 'utf-7 :charset-list '(unicode) :pre-write-conversion 'utf-7-pre-write-conversion diff --git a/lisp/language/cyrillic.el b/lisp/language/cyrillic.el index 7af87e65703..f923c84e221 100644 --- a/lisp/language/cyrillic.el +++ b/lisp/language/cyrillic.el @@ -126,7 +126,8 @@ 'cp878 (define-coding-system 'koi8-u "KOI8-U 8-bit encoding for Cyrillic (MIME: KOI8-U)" :coding-type 'charset - :mnemonic ?U + ;; This used to be ?U which collided with UTF-8. + :mnemonic ?\N{cyrillic capital letter u} ; У :charset-list '(koi8-u) :mime-charset 'koi8-u) commit 25f35957c98fb9ae591cce413f3120f06b0bfdc2 Author: Vladimir Sedach Date: Mon Jun 26 22:32:07 2023 -0600 Fix 'shell-dirtrack-mode' showing as enabled in unrelated buffers * lisp/shell.el (shell-dirtrack-mode): Reverse the alias. (shell-dirtrack-mode): Move before first use of the variable. Add :interactive keyword. (shell-directory-tracker, shell-cd): Use 'shell-dirtrack-mode' instead of 'shell-dirtrackp'. (Bug#64311) diff --git a/lisp/shell.el b/lisp/shell.el index b74442f1961..0a24b4ea4c2 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -346,10 +346,10 @@ shell-dirstack "List of directories saved by pushd in this buffer's shell. Thus, this does not include the shell's current directory.") -(defvaralias 'shell-dirtrack-mode 'shell-dirtrackp) - -(defvar shell-dirtrackp t - "Non-nil in a shell buffer means directory tracking is enabled.") +(defvaralias 'shell-dirtrackp 'shell-dirtrack-mode + "Non-nil in a shell buffer means directory tracking is enabled. +Directory tracking (`shell-dirtrack-mode') is automatically enabled +when `shell-mode' is activated.") (defvar shell-last-dir nil "Keep track of last directory for ksh `cd -' command.") @@ -997,6 +997,21 @@ shell ;; replace it with a process filter that watches for and strips out ;; these messages. +(define-minor-mode shell-dirtrack-mode + "Toggle directory tracking in this shell buffer (Shell Dirtrack mode). +This assigns a buffer-local non-nil value to `shell-dirtrackp'. + +The `dirtrack' package provides an alternative implementation of +this feature; see the function `dirtrack-mode'. Also see +`comint-osc-directory-tracker' for an escape-sequence based +solution." + :lighter nil + :interactive (shell-mode) + (setq list-buffers-directory (if shell-dirtrack-mode default-directory)) + (if shell-dirtrack-mode + (add-hook 'comint-input-filter-functions #'shell-directory-tracker nil t) + (remove-hook 'comint-input-filter-functions #'shell-directory-tracker t))) + (defun shell-directory-tracker (str) "Tracks cd, pushd and popd commands issued to the shell. This function is called on each input passed to the shell. @@ -1013,7 +1028,7 @@ shell-directory-tracker and `shell-pushd-dunique' control the behavior of the relevant command. Environment variables are expanded, see function `substitute-in-file-name'." - (if shell-dirtrackp + (if shell-dirtrack-mode ;; We fail gracefully if we think the command will fail in the shell. ;;; (with-demoted-errors "Directory tracker failure: %s" ;; This fails so often that it seems better to just ignore errors (?). @@ -1167,23 +1182,10 @@ shell-extract-num (and (string-match "^\\+[1-9][0-9]*$" str) (string-to-number str))) -(define-minor-mode shell-dirtrack-mode - "Toggle directory tracking in this shell buffer (Shell Dirtrack mode). - -The `dirtrack' package provides an alternative implementation of -this feature; see the function `dirtrack-mode'. Also see -`comint-osc-directory-tracker' for an escape-sequence based -solution." - :lighter nil - (setq list-buffers-directory (if shell-dirtrack-mode default-directory)) - (if shell-dirtrack-mode - (add-hook 'comint-input-filter-functions #'shell-directory-tracker nil t) - (remove-hook 'comint-input-filter-functions #'shell-directory-tracker t))) - (defun shell-cd (dir) "Do normal `cd' to DIR, and set `list-buffers-directory'." (cd dir) - (if shell-dirtrackp + (if shell-dirtrack-mode (setq list-buffers-directory default-directory))) (defun shell-resync-dirs () commit a9420c89da925f5a34acfd0a5c016a1de0ea7581 Author: Stefan Monnier Date: Tue Jul 4 19:58:12 2023 -0400 Avoid aborts when trying to 'read' sub-char-tables * src/data.c (Ftype_of): Support 'sub-char-table'. (Bug#64450) * src/lisp.h: Fix commentary of char-table. diff --git a/src/data.c b/src/data.c index 9d7e7effdcd..6de8e0cf1a1 100644 --- a/src/data.c +++ b/src/data.c @@ -269,10 +269,11 @@ DEFUN ("type-of", Ftype_of, Stype_of, 1, 1, 0, return Qtreesit_compiled_query; case PVEC_SQLITE: return Qsqlite; + case PVEC_SUB_CHAR_TABLE: + return Qsub_char_table; /* "Impossible" cases. */ case PVEC_MISC_PTR: case PVEC_OTHER: - case PVEC_SUB_CHAR_TABLE: case PVEC_FREE: ; } emacs_abort (); @@ -4215,6 +4216,7 @@ #define PUT_ERROR(sym, tail, msg) \ DEFSYM (Qvector, "vector"); DEFSYM (Qrecord, "record"); DEFSYM (Qchar_table, "char-table"); + DEFSYM (Qsub_char_table, "sub-char-table"); DEFSYM (Qbool_vector, "bool-vector"); DEFSYM (Qhash_table, "hash-table"); DEFSYM (Qthread, "thread"); diff --git a/src/lisp.h b/src/lisp.h index f10bce86b45..b18d0a69786 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2011,9 +2011,7 @@ ASCII_CHAR_P (intmax_t c) range of characters. A sub-char-table is like a vector, but with two integer fields between the header and Lisp data, which means that it has to be marked with some precautions (see mark_char_table - in alloc.c). A sub-char-table appears only in an element of a - char-table, and there's no way to access it directly from a Lisp - program. */ + in alloc.c). A sub-char-table appears in an element of a char-table. */ enum CHARTAB_SIZE_BITS { commit 600b90ed56854e8460038ca6b8aaa1feae4ab2c9 Author: Mattias Engdegård Date: Fri Jul 7 14:40:37 2023 +0200 Mark failing icalendar test as unstable (bug#56241) * test/lisp/calendar/icalendar-tests.el (icalendar-export-bug-56241-dotted-pair): This test started failing early July 2023 in multiple branches at once without any change to the code and is likely sensitive to the current date. Tag it to keep it quiet for now. diff --git a/test/lisp/calendar/icalendar-tests.el b/test/lisp/calendar/icalendar-tests.el index 27076f5ce1f..9071607005d 100644 --- a/test/lisp/calendar/icalendar-tests.el +++ b/test/lisp/calendar/icalendar-tests.el @@ -999,6 +999,9 @@ icalendar-tests--diary-float (ert-deftest icalendar-export-bug-56241-dotted-pair () "See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56241#5" + ;; This test started failing early July 2023 without any apparent change + ;; to the underlying code, so is probably sensitive to the current date. + :tags '(:unstable) (let ((icalendar-export-sexp-enumeration-days 366)) (mapc (lambda (diary-string) (should (string= "" (icalendar-tests--get-error-string-for-export commit f8a918c9778f4335d547076622b138679d76a9d7 Author: Eli Zaretskii Date: Fri Jul 7 10:29:55 2023 +0300 ; * src/coding.c (Fcoding_system_put): Improve doc string. diff --git a/src/coding.c b/src/coding.c index 49dcd8634f3..544f98dcdab 100644 --- a/src/coding.c +++ b/src/coding.c @@ -11447,7 +11447,18 @@ DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal, DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, 3, 3, 0, - doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */) + doc: /* Change value of CODING-SYSTEM's property PROP to VAL. + +The following properties, if set by this function, override the values +of the corresponding attributes set by `define-coding-system': + + `:mnemonic', `:default-char', `:ascii-compatible-p' + `:decode-translation-table', `:encode-translation-table', + `:post-read-conversion', `:pre-write-conversion' + +See `define-coding-system' for the description of these properties. +See `coding-system-get' and `coding-system-plist' for accessing the +property list of a coding-system. */) (Lisp_Object coding_system, Lisp_Object prop, Lisp_Object val) { Lisp_Object spec, attrs; commit 40f84e906f67eeefd51076747396aaa1354a8dd6 Author: Eli Zaretskii Date: Fri Jul 7 09:59:52 2023 +0300 ; * doc/lispref/keymaps.texi (Key Binding Commands): Fix typo. diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index ab862e75bb5..9e36d6716b9 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi @@ -2071,7 +2071,7 @@ Key Binding Commands This section describes some convenient interactive interfaces for changing key bindings. They work by calling @code{keymap-set} -(@pxref{Changing key Bindings}). In interactive use, these commands +(@pxref{Changing Key Bindings}). In interactive use, these commands prompt for the argument @var{key} and expect the user to type a valid key sequence; they also prompt for the @var{binding} of the key sequence, and expect the name of a command (i.e., a symbol that commit 502a7800319b468df7c6bfeac66498d44fcba390 Author: Eli Zaretskii Date: Fri Jul 7 09:26:58 2023 +0300 ; Improve documentation of 'vertical-motion' in ELisp manual * doc/lispref/positions.texi (Screen Lines): Improve the documentation of 'vertical-motion'. diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index d8115ac3ad3..e74a165b9ed 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi @@ -560,16 +560,23 @@ Screen Lines @defun vertical-motion count &optional window cur-col This function moves point to the start of the screen line @var{count} screen lines down from the screen line containing point. If @var{count} -is negative, it moves up instead. - -The @var{count} argument can be a cons cell, @code{(@var{cols} -. @var{lines})}, instead of an integer. Then the function moves by -@var{lines} screen lines, and puts point @var{cols} columns from the -visual start of that screen line. Note that @var{cols} are counted -from the @emph{visual} start of the line; if the window is scrolled -horizontally (@pxref{Horizontal Scrolling}), the column on which point -will end is in addition to the number of columns by which the text is -scrolled. +is negative, it moves up instead. If @var{count} is zero, point moves +to the visual start of the current screen line. + +The @var{count} argument can be a cons cell, @w{@code{(@var{cols} +. @var{lines})}}, instead of an integer. Then the function moves by +@var{lines} screen lines, as described for @var{count} above, and puts +point @var{cols} columns from the visual start of that screen line. +The value of @var{cols} can be a float, and is interpreted in units of +the frame's canonical character width (@pxref{Frame Font}); this +allows specifying accurate horizontal position of point when the +target screen line uses variable fonts. Note that @var{cols} are +counted from the @emph{visual} start of the line; if the window is +scrolled horizontally (@pxref{Horizontal Scrolling}), the column where +point will end is in addition to the number of columns by which the +text is scrolled, and if the target line is a continuation line, its +leftmost column is considered column zero (unlike column-oriented +functions, @pxref{Columns}). The return value is the number of screen lines over which point was moved. The value may be less in absolute value than @var{count} if commit 0d90873fa41c17398238752024c8fd17d4f88f43 Author: Eli Zaretskii Date: Fri Jul 7 09:16:12 2023 +0300 ; * src/indent.c (Fvertical_motion): Doc fix. diff --git a/src/indent.c b/src/indent.c index aef394dab88..d5575d2f00e 100644 --- a/src/indent.c +++ b/src/indent.c @@ -2149,21 +2149,33 @@ DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 3, 0, This function is an ordinary cursor motion function which calculates the new position based on how text would be displayed. The new position may be the start of a line, -or just the start of a continuation line. +or the start of a continuation line, +or the start of the visible portion of a horizontally-scrolled line. + The function returns number of screen lines moved over; -that usually equals LINES, but may be closer to zero -if beginning or end of buffer was reached. +that usually equals LINES, but may be closer to zero if +beginning or end of buffer was reached. The optional second argument WINDOW specifies the window to use for parameters such as width, horizontal scrolling, and so on. The default is to use the selected window's parameters. +If LINES is zero, point will move to the first visible character on +the current screen line. + LINES can optionally take the form (COLS . LINES), in which case the -motion will not stop at the start of a screen line but COLS column -from the visual start of the line (if such exists on that line, that -is). If the line is scrolled horizontally, COLS is interpreted -visually, i.e., as addition to the columns of text beyond the left -edge of the window. +motion will stop at the COLSth column from the visual start of the +line (if such column exists on that line, that is). If the line is +scrolled horizontally, COLS is interpreted visually, i.e., as addition +to the columns of text beyond the left edge of the window. +If LINES is a cons cell, its car COLS can be a float, which allows +specifying an accurate position of point on a screen line that mixes +fonts or uses variable-pitch font: COLS is interpreted in units of the +canonical character width, and is internally converted to pixel units; +point will then stop at the position closest to that pixel coordinate. +The cdr of the cons, LINES, must be an integer; if it is zero, this +function moves point horizontally in the current screen line, to the +position specified by COLS. The optional third argument CUR-COL specifies the horizontal window-relative coordinate of point, in units of frame's canonical @@ -2171,11 +2183,10 @@ DEFUN ("vertical-motion", Fvertical_motion, Svertical_motion, 1, 3, 0, omitted or nil, the function will determine the point coordinate by going back to the beginning of the line. -`vertical-motion' always uses the current buffer, -regardless of which buffer is displayed in WINDOW. -This is consistent with other cursor motion functions -and makes it possible to use `vertical-motion' in any buffer, -whether or not it is currently displayed in some window. */) +`vertical-motion' always uses the current buffer, regardless of which +buffer is displayed in WINDOW. This is consistent with other cursor +motion functions and makes it possible to use `vertical-motion' in any +buffer, whether or not it is currently displayed in some window. */) (Lisp_Object lines, Lisp_Object window, Lisp_Object cur_col) { struct it it; commit 9b38773a20b43e2354ddf036ffa28e397537da3f Author: Eli Zaretskii Date: Thu Jul 6 13:12:21 2023 +0300 ; * lisp/dired.el (dired-no-confirm): Doc fix. (Bug#64493) diff --git a/lisp/dired.el b/lisp/dired.el index de875302793..d14cf47ffd5 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3881,13 +3881,20 @@ dired-mark-prompt (format "%c [%d files]" dired-marker-char count))))) (defcustom dired-no-confirm nil - "A list of symbols for commands Dired should not confirm, or t. -Command symbols are `byte-compile', `chgrp', `chmod', `chown', `compress', -`copy', `delete', `hardlink', `load', `move', `print', `shell', `symlink', -`touch' and `uncompress'. -If t, confirmation is never needed." + "Dired commands for which Dired should not popup list of affected files, or t. + +If non-nil, Dired will not pop up the list of files to be affected by +some Dired commands, when asking for confirmation. (Dired will still +ask for confirmation, just without showing the affected files.) + +If the value is t, the list of affected files is never popped up. +The value can also be a list of command symbols: then the list of the +affected files will not be popped up only for the corresponding Dired +commands. Recognized command symbols are `byte-compile', `chgrp', +`chmod', `chown', `compress', `copy', `delete', `hardlink', `load', +`move', `print', `shell', `symlink', `touch' and `uncompress'." :group 'dired - :type '(choice (const :tag "Confirmation never needed" t) + :type '(choice (const :tag "Affected files never shown" t) (set (const byte-compile) (const chgrp) (const chmod) (const chown) (const compress) (const copy) (const delete) (const hardlink) commit a30ebe7a5564d3352b9812b1e6fb85d7da6cd88d Author: Eli Zaretskii Date: Thu Jul 6 11:42:01 2023 +0300 ; Improve documentation of key-binding commands * doc/lispref/keymaps.texi (Key Binding Commands): Improve the documentation of arguments expected by key binding commands. * lisp/keymap.el (keymap-set, keymap-global-set) (keymap-local-set, keymap-global-unset, keymap-local-unset) (keymap-unset, key-parse): Doc fixes. diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index bbf7138b5be..ab862e75bb5 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi @@ -2070,7 +2070,16 @@ Key Binding Commands @section Commands for Binding Keys This section describes some convenient interactive interfaces for -changing key bindings. They work by calling @code{keymap-set}. +changing key bindings. They work by calling @code{keymap-set} +(@pxref{Changing key Bindings}). In interactive use, these commands +prompt for the argument @var{key} and expect the user to type a valid +key sequence; they also prompt for the @var{binding} of the key +sequence, and expect the name of a command (i.e., a symbol that +satisfies @code{commandp}, @pxref{Interactive Call}). When called +from Lisp, these commands expect @var{key} to be a string that +satisfies @code{key-valid-p} (@pxref{Key Sequences}), and +@var{binding} to be any Lisp object that is meaningful in a keymap +(@pxref{Key Lookup}). People often use @code{keymap-global-set} in their init files (@pxref{Init File}) for simple customization. For example, diff --git a/lisp/keymap.el b/lisp/keymap.el index dccc0a3cd31..cd06b830e0a 100644 --- a/lisp/keymap.el +++ b/lisp/keymap.el @@ -40,11 +40,12 @@ keymap--compile-check (defun keymap-set (keymap key definition) "Set KEY to DEFINITION in KEYMAP. KEY is a string that satisfies `key-valid-p'. +If DEFINITION is a string, it must also satisfy `key-valid-p'. DEFINITION is anything that can be a key's definition: nil (means key is undefined in this keymap), a command (a Lisp function suitable for interactive calling), - a string (treated as a keyboard macro), + a string (treated as a keyboard macro or a sequence of input events), a keymap (to define a prefix key), a symbol (when the key is looked up, the symbol will stand for its function definition, which should at that time be one of the above, @@ -67,10 +68,17 @@ keymap-set (defun keymap-global-set (key command &optional interactive) "Give KEY a global binding as COMMAND. -COMMAND is the command definition to use; usually it is -a symbol naming an interactively-callable function. +When called interactively, KEY is a key sequence. When called from +Lisp, KEY is a string that must satisfy `key-valid-p'. -KEY is a string that satisfies `key-valid-p'. +COMMAND is the command definition to use. When called interactively, +this function prompts for COMMAND and accepts only names of known +commands, i.e., symbols that satisfy the `commandp' predicate. When +called from Lisp, COMMAND can be anything that `keymap-set' accepts +as its DEFINITION argument. + +If COMMAND is a string (which can only happen when this function is +callled from Lisp), it must satisfy `key-valid-p'. Note that if KEY has a local binding in the current buffer, that local binding will continue to shadow any global binding @@ -84,12 +92,19 @@ keymap-global-set (defun keymap-local-set (key command &optional interactive) "Give KEY a local binding as COMMAND. -COMMAND is the command definition to use; usually it is -a symbol naming an interactively-callable function. +When called interactively, KEY is a key sequence. When called from +Lisp, KEY is a string that must satisfy `key-valid-p'. -KEY is a string that satisfies `key-valid-p'. +COMMAND is the command definition to use. When called interactively, +this function prompts for COMMAND and accepts only names of known +commands, i.e., symbols that satisfy the `commandp' predicate. When +called from Lisp, COMMAND can be anything that `keymap-set' accepts +as its DEFINITION argument. -The binding goes in the current buffer's local map, which in most +If COMMAND is a string (which can only happen when this function is +callled from Lisp), it must satisfy `key-valid-p'. + +The binding goes in the current buffer's local keymap, which in most cases is shared with all other buffers in the same major mode." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form)) (advertised-calling-convention (key command) "29.1")) @@ -103,10 +118,11 @@ keymap-local-set (defun keymap-global-unset (key &optional remove) "Remove global binding of KEY (if any). -KEY is a string that satisfies `key-valid-p'. +When called interactively, KEY is a key sequence. When called from +Lisp, KEY is a string that satisfies `key-valid-p'. -If REMOVE (interactively, the prefix arg), remove the binding -instead of unsetting it. See `keymap-unset' for details." +If REMOVE is non-nil (interactively, the prefix arg), remove the +binding instead of unsetting it. See `keymap-unset' for details." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))) (interactive (list (key-description (read-key-sequence "Unset key globally: ")) @@ -115,10 +131,11 @@ keymap-global-unset (defun keymap-local-unset (key &optional remove) "Remove local binding of KEY (if any). -KEY is a string that satisfies `key-valid-p'. +When called interactively, KEY is a key sequence. When called from +Lisp, KEY is a string that satisfies `key-valid-p'. -If REMOVE (interactively, the prefix arg), remove the binding -instead of unsetting it. See `keymap-unset' for details." +If REMOVE is non-nil (interactively, the prefix arg), remove the +binding instead of unsetting it. See `keymap-unset' for details." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))) (interactive (list (key-description (read-key-sequence "Unset key locally: ")) @@ -130,11 +147,11 @@ keymap-unset "Remove key sequence KEY from KEYMAP. KEY is a string that satisfies `key-valid-p'. -If REMOVE, remove the binding instead of unsetting it. This only -makes a difference when there's a parent keymap. When unsetting -a key in a child map, it will still shadow the same key in the -parent keymap. Removing the binding will allow the key in the -parent keymap to be used." +If REMOVE is non-nil, remove the binding instead of unsetting it. +This only makes a difference when there's a parent keymap. When +unsetting a key in a child map, it will still shadow the same key +in the parent keymap. Removing the binding will allow the key in +the parent keymap to be used." (declare (compiler-macro (lambda (form) (keymap--compile-check key) form))) (keymap--check key) (define-key keymap (key-parse key) nil remove)) @@ -201,7 +218,8 @@ keymap-set-after (defun key-parse (keys) "Convert KEYS to the internal Emacs key representation. -See `kbd' for a descripion of KEYS." +KEYS should be a string describing a key sequence in the format +returned by \\[describe-key] (`describe-key')." (declare (pure t) (side-effect-free t)) ;; A pure function is expected to preserve the match data. (save-match-data commit c3fefb2b3ae098068bc03cc305b9181746d72751 Author: Robert Pluim Date: Tue Jul 4 17:44:43 2023 +0200 Improve natnump shortdoc * lisp/emacs-lisp/shortdoc.el (number): Make it clear that zero satisfies 'natnump'. Move 'natnump' next to 'cl-plusp' to highlight the difference between them. diff --git a/lisp/emacs-lisp/shortdoc.el b/lisp/emacs-lisp/shortdoc.el index 871233097a7..f5cbb2e645f 100644 --- a/lisp/emacs-lisp/shortdoc.el +++ b/lisp/emacs-lisp/shortdoc.el @@ -1247,6 +1247,10 @@ number :eval (>= 3 2 2 1)) (zerop :eval (zerop 0)) + (natnump + :eval (natnump -1) + :eval (natnump 0) + :eval (natnump 23)) (cl-plusp :eval (cl-plusp 0) :eval (cl-plusp 1)) @@ -1257,9 +1261,6 @@ number :eval (cl-oddp 3)) (cl-evenp :eval (cl-evenp 6)) - (natnump - :eval (natnump -1) - :eval (natnump 23)) (bignump :eval (bignump 4) :eval (bignump (expt 2 90))) commit 244d4c837ab04a3218cef74bc886f6a38ae0f481 Author: Robert Pluim Date: Tue Jul 4 17:21:54 2023 +0200 correct info documentation of benchmark-call * doc/lispref/debugging.texi (Profiling): 'benchmark-call' is a defun, not a macro. diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi index ea11d2d8d9c..169e3ac37d3 100644 --- a/doc/lispref/debugging.texi +++ b/doc/lispref/debugging.texi @@ -1102,9 +1102,9 @@ Profiling You can measure the time it takes to evaluate individual Emacs Lisp forms using the @file{benchmark} library. See the function @code{benchmark-call} as well as the macros @code{benchmark-run}, -@code{benchmark-run-compiled}, @code{benchmark-progn} and -@code{benchmark-call} in @file{benchmark.el}. You can also use the -@code{benchmark} command for timing forms interactively. +@code{benchmark-run-compiled}, and @code{benchmark-progn} in +@file{benchmark.el}. You can also use the @code{benchmark} command +for timing forms interactively. @c Not worth putting in the printed manual. @ifnottex commit 67def1f55021b054eabee54cf560075d9aa29379 Author: Juri Linkov Date: Mon Jul 3 21:50:44 2023 +0300 * lisp/progmodes/grep.el (rgrep): Fix docstring. Instead of the incorrect key `M-c' produce the right key with \\\\[read-regexp-toggle-case-fold]. diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 0da16b44dda..3fb16713cc1 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -1236,9 +1236,10 @@ rgrep If CONFIRM is non-nil, the user will be given an opportunity to edit the command before it's run. -Interactively, the user can use the \\`M-c' command while entering -the regexp to indicate whether the grep should be case sensitive -or not." +Interactively, the user can use \ +\\\\[read-regexp-toggle-case-fold] \ +while entering the regexp +to indicate whether the grep should be case sensitive or not." (interactive (progn (grep-compute-defaults) commit 8da2091362d106bedd282e25ff8f14df29399619 Author: Eli Zaretskii Date: Mon Jul 3 16:14:45 2023 +0300 ; Fix documentation of minibuffer-completion commands * doc/emacs/mini.texi (Completion Commands): Index more keys and commands. (Bug#64425) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index c2e13adb08f..201d4e5941d 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -383,18 +383,27 @@ Completion Commands @table @kbd @vindex minibuffer-completion-auto-choose +@kindex M-DOWN +@kindex M-UP +@kindex M-RET +@findex minibuffer-next-completion +@findex minibuffer-previous-completion +@findex minibuffer-choose-completion @item M-@key{DOWN} @itemx M-@key{UP} -While in the minibuffer, these keys navigate through the completions -displayed in the completions buffer. When +While in the minibuffer, @kbd{M-@key{DOWN}} +(@code{minibuffer-next-completion} and @kbd{M-@key{UP}} +(@code{minibuffer-previous-completion}) navigate through the +completions and displayed in the completions buffer. When @code{minibuffer-completion-auto-choose} is non-@code{nil} (which is the default), using these commands also inserts the current completion candidate into the minibuffer. If @code{minibuffer-completion-auto-choose} is @code{nil}, you can use -the @kbd{M-@key{RET}} command to insert the completion candidates into -the minibuffer. By default, that exits the minibuffer, but with a -prefix argument, @kbd{C-u M-@key{RET}} inserts the currently active -candidate without exiting the minibuffer. +the @kbd{M-@key{RET}} command (@code{minibuffer-choose-completion}) to +insert the completion candidates into the minibuffer. By default, +that exits the minibuffer, but with a prefix argument, @kbd{C-u +M-@key{RET}} inserts the currently active candidate without exiting +the minibuffer. @findex switch-to-completions @item M-v commit aa030698cef077d268a854ad83ab5da18a5a1017 Author: Eli Zaretskii Date: Mon Jul 3 15:12:12 2023 +0300 ; Fix typos in documented names of keymap-* functions * doc/lispref/keymaps.texi (Functions for Key Lookup): Fix typos in function names. (Bug#64434) diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index 6d07ad5be2c..bbf7138b5be 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi @@ -1338,7 +1338,7 @@ Functions for Key Lookup not cause an error. @end deffn -@defun keymap-local-binding key &optional accept-defaults +@defun keymap-local-lookup key &optional accept-defaults This function returns the binding for @var{key} in the current local keymap, or @code{nil} if it is undefined there. @@ -1346,7 +1346,7 @@ Functions for Key Lookup as in @code{keymap-lookup} (above). @end defun -@defun keymap-global-binding key &optional accept-defaults +@defun keymap-global-lookup key &optional accept-defaults This function returns the binding for command @var{key} in the current global keymap, or @code{nil} if it is undefined there. commit a9b46bb25df38e0ca89784afac230408b620b2dc Author: Spencer Baugh Date: Sun Jul 2 12:11:09 2023 -0400 Include a help-echo for flymake's modeline counters This helps clarify what each of these numbers mean. This is inspired by 'compilation-mode-line-errors' which does the same. * lisp/progmodes/flymake.el (flymake--mode-line-counter): Add help-echo to mode line properties. (Bug#64424) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 6f293acca5e..47dc32f9245 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1473,6 +1473,12 @@ flymake--mode-line-counter ,(format "%d" count) face ,face mouse-face mode-line-highlight + help-echo ,(format "Number of %s; scroll mouse to view." + (cond + ((eq type :error) "errors") + ((eq type :warning) "warnings") + ((eq type :note) "notes") + (t (format "%s diagnostics" type)))) keymap ,(let ((map (make-sparse-keymap))) (define-key map (vector 'mode-line commit 37ed3d15f38339400eba67647c87fad85de3a384 Author: Eli Zaretskii Date: Sun Jul 2 09:16:58 2023 +0300 Avoid errors in completion due to 'completion-regexp-list' * doc/lispref/minibuf.texi (Basic Completion): * src/minibuf.c (syms_of_minibuf) : Document that global non-nil settings of 'completion-regexp-list' are not safe. * lisp/minibuffer.el (completion-pcm--merge-completions): Avoid errors in 'try-completion' when PREFIX is nil. (Bug#64351) diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 52eea3b9535..7fbdd9eb6e2 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -1052,6 +1052,12 @@ Basic Completion consider a completion acceptable if it matches all regular expressions in this list, with @code{case-fold-search} (@pxref{Searching and Case}) bound to the value of @code{completion-ignore-case}. + +Do not set this variable to a non-@code{nil} value globally, as that +is not safe and will probably cause errors in completion commands. +This variable should be only let-bound to non-@code{nil} values around +calls to basic completion functions: @code{try-completion}, +@code{test-completion}, and @code{all-completions}. @end defvar @defmac lazy-completion-table var fun diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 4aa1ab3e890..3e30b68d5e9 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -4027,7 +4027,8 @@ completion-pcm--merge-completions (setq ccs (nreverse ccs)) (let* ((prefix (try-completion fixed comps)) (unique (or (and (eq prefix t) (setq prefix fixed)) - (eq t (try-completion prefix comps))))) + (and (stringp prefix) + (eq t (try-completion prefix comps)))))) (unless (or (eq elem 'prefix) (equal prefix "")) (push prefix res)) diff --git a/src/minibuf.c b/src/minibuf.c index 6e54d8c3ba5..58adde1bf66 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -2471,7 +2471,12 @@ syms_of_minibuf (void) if it matches all regular expressions in this list, with `case-fold-search' bound to the value of `completion-ignore-case'. See Info node `(elisp)Basic Completion', for a description of these -functions. */); +functions. + +Do not set this variable to a non-nil value globally, as that is not +safe and will probably cause errors in completion commands. This +variable should be only let-bound to non-nil values around calls to +basic completion functions like `try-completion' and `all-completions'. */); Vcompletion_regexp_list = Qnil; DEFVAR_BOOL ("minibuffer-allow-text-properties", commit 15ff87617772c2a2c3d8a3a1e2ed7f96e527ad9e Author: Eli Zaretskii Date: Sun Jul 2 08:27:05 2023 +0300 ; * lisp/register.el (register-val-describe): Doc fix. diff --git a/lisp/register.el b/lisp/register.el index 06a52a3850e..ca6de450993 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -380,9 +380,7 @@ describe-register-1 (cl-defgeneric register-val-describe (val verbose) "Print description of register value VAL to `standard-output'. -Second argument VERBOSE is ignored, unless VAL is not one of the -supported kinds of register contents, in which case it is displayed -using `prin1'." +Second argument VERBOSE means produce a more detailed description." (princ "Garbage:\n") (if verbose (prin1 val))) commit fe7b909c16cb7fd4a65975285b566448cb486521 Author: Michael Heerdegen Date: Sun Jul 2 03:35:34 2023 +0200 ; Fix two typos in recent changes in the manual * doc/lispref/text.texi (Property Search): * lisp/register.el (register-preview-function): Fix typos. diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 342e23beadb..82e79e2bc14 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -3424,7 +3424,7 @@ Property Search region where we have a property match, skip past that region and find the next region instead. -The @code{prop-match} structure has the following accessor functionss: +The @code{prop-match} structure has the following accessor functions: @code{prop-match-beginning} (the start of the match), @code{prop-match-end} (the end of the match), and @code{prop-match-value} (the value of @var{property} at the start of diff --git a/lisp/register.el b/lisp/register.el index 56ab089efb7..06a52a3850e 100644 --- a/lisp/register.el +++ b/lisp/register.el @@ -126,7 +126,7 @@ register-preview-default (defvar register-preview-function #'register-preview-default "Function to format a register for previewing. Called with one argument, a cons (NAME . CONTENTS) as found in `register-alist'. -The function should return a string, the description of teh argument.") +The function should return a string, the description of the argument.") (defun register-preview (buffer &optional show-empty) "Pop up a window showing the registers preview in BUFFER. commit 7a74b8c32773633983089623203aea21b7f43afa Author: Alan Mackenzie Date: Sat Jul 1 11:17:31 2023 +0000 C Mode: Don't fontify foo globally as type due to "struct foo" This fixes bug#64322. * lisp/progmodes/cc-langs.el (c-typeless-decl-kwds): Make the entry for c-mode nil. diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index e6c6c65f59c..f7779100b04 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -2240,7 +2240,7 @@ c-simple-decl-matchers (c-forward-syntactic-ws)) (goto-char (match-end ,type-match)))))))) - ;; Fontify special declarations that lacks a type. + ;; Fontify special declarations that lack a type. ,@(when (c-lang-const c-typeless-decl-kwds) `((,(c-make-font-lock-search-function (concat "\\<\\(" diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 1749a2dfa7a..a2476561856 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -2588,6 +2588,7 @@ c-typeless-decl-kwds ;; {...}"). t (append (c-lang-const c-class-decl-kwds) (c-lang-const c-brace-list-decl-kwds)) + c nil ;; Note: "manages" for CORBA CIDL clashes with its presence on ;; `c-type-list-kwds' for IDL. idl (append (c-lang-const c-typeless-decl-kwds) commit 823bf6bdb1a525f60f4b64620c36f89df964ff07 Author: Mattias Engdegård Date: Sat Jul 1 12:27:09 2023 +0200 * lisp/rect.el (rectangle--duplicate-right): Fix rectangle dup bug. This is a necessary adjustment to changes to rect.el in Emacs 29. diff --git a/lisp/rect.el b/lisp/rect.el index 5ff821abb3f..cdfd0764b99 100644 --- a/lisp/rect.el +++ b/lisp/rect.el @@ -940,7 +940,8 @@ rectangle--duplicate-right (move-to-column endcol t) (dotimes (_ n) (insert (cadr lines))))) - (region-beginning) (region-end)) + (min (point) (mark)) + (max (point) (mark))) ;; Recompute the rectangle state; no crutches should be needed now. (let ((p (point)) (m (mark))) commit e339d0080d33a17bb1dee84160db7d89de8502cd Author: Mattias Engdegård Date: Sat Jul 1 12:26:15 2023 +0200 ; * test/lisp/misc-tests.el (ert): require misc to avoid warning diff --git a/test/lisp/misc-tests.el b/test/lisp/misc-tests.el index ea27ea1653b..54bb44b7d01 100644 --- a/test/lisp/misc-tests.el +++ b/test/lisp/misc-tests.el @@ -24,6 +24,7 @@ ;;; Code: (require 'ert) +(require 'misc) (defmacro with-misc-test (original result &rest body) (declare (indent 2))