emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 89e7bb230d: Merge from origin/emacs-29


From: Stefan Kangas
Subject: master 89e7bb230d: Merge from origin/emacs-29
Date: Fri, 30 Dec 2022 00:45:20 -0500 (EST)

branch: master
commit 89e7bb230d643b3619d7e2ed6855c35184032542
Merge: 9153cf8158 644c71d678
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Merge from origin/emacs-29
    
    644c71d6788 lisp/textmodes/bibtex.el: fix bibtex-beginning-of-entry (...
    ab38abfdf75 lisp/textmodes/bibtex.el: Treat $ as punctuation in BibTe...
    d086cd6cf87 Clarify the documentation of 'set-face-attribute'
    dafa6d6badd Handle non-string values in pcomplete
    beed746f944 Fix completion when completion-auto-select is set
    7ccb88486eb ; * etc/DEBUG: Update MS-Windows specifics for GDB 13 and...
    558b59d81b9 Add color fontification in css-ts-mode (bug#60405)
    a96a7c81151 ; * lisp/textmodes/css-mode.el (css-ts-mode): Fix imenu s...
    793641a3db5 ; * lisp/progmodes/js.el: Fix byte-compile warning.
    0aea1cf8190 * lisp/hi-lock.el (hi-lock--regexps-at-point): Fix bug (b...
    60418e6f09c * src/keyboard.c (echo_add_key): Use recently rebound C-h...
    706ed852855 Avoid assertion violations in treesit.c with --enable-che...
    38c35bf0f6a Clean up treesit-default-defun-skipper and add comments
    9371d488be6 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
    9d814bea460 ; whitespace.el: Use the new 'ert-with-buffer-selected' i...
    784e509bded Fix c-ts-mode bracket indentation (bug#60398)
---
 doc/lispref/display.texi      | 28 +++++++++++++++++-----------
 etc/DEBUG                     |  9 +++++++--
 lisp/faces.el                 |  4 ++++
 lisp/hi-lock.el               | 33 +++++++++++++++++++--------------
 lisp/minibuffer.el            |  5 ++++-
 lisp/pcomplete.el             | 27 ++++++++++++++++++++-------
 lisp/progmodes/c-ts-mode.el   | 20 ++++++++++++++++++--
 lisp/progmodes/js.el          |  7 +++++--
 lisp/textmodes/bibtex.el      | 28 ++++++++++++++++++++--------
 lisp/textmodes/css-mode.el    | 10 +++++++---
 lisp/treesit.el               | 18 +++++++++++-------
 src/keyboard.c                |  5 ++---
 src/treesit.c                 |  7 +++----
 test/lisp/whitespace-tests.el | 13 +++----------
 14 files changed, 140 insertions(+), 74 deletions(-)

diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 3743499454..5397489e44 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -3057,17 +3057,23 @@ If @var{frame} is @code{t}, this function sets the 
default attributes
 for newly created frames; they will effectively override the attribute
 values specified by @code{defface}.  If @var{frame} is @code{nil},
 this function sets the attributes for all existing frames, as well as
-for newly created frames.  However, if you want to @emph{reset} the
-value of an attribute to @code{unspecified} in a way that also affects
-newly created frames, you @emph{must} explicitly call this function
-with @var{frame} set to @code{t} and the value of the attribute set to
-@code{unspecified} (@emph{not} @code{nil}!@:), in addition to the call
-with @var{frame} set to @code{nil}.  This is because the default
-attributes for newly created frames are merged with the face's spec in
-@code{defface} when a new frame is created, and so having
-@code{unspecified} in the default attributes for new frames will be
-unable to override @code{defface}; the special call to this function
-as described above will arrange for @code{defface} to be overridden.
+for newly created frames.
+
+To @emph{unset} the value of an attribute, that is, to indicate that
+the face doesn't by itself specify a value for the attribute, the
+special value @code{unspecified} (@emph{not} @code{nil}!@:) must be
+used.
+
+Note that the attribute-value pairs are evaluated in the order they
+are specified, except the @code{:family} and @code{:foundry}
+attributes, which are evaluated first.  This means both that only the
+last value of a given attribute will be used, and that in some cases a
+different order will give different results.  For example, when
+@code{:weight} is placed before @code{:font}, the weight value is
+applied to the current font of the face, and might be rounded to the
+closest available weight of that font, whereas when @code{:font} is
+placed before @code{:weight} the weight value is applied to the
+specified font.
 @end defun
 
   The following commands and functions mostly provide compatibility
diff --git a/etc/DEBUG b/etc/DEBUG
index 01c75f8da7..382e7cb7b6 100644
--- a/etc/DEBUG
+++ b/etc/DEBUG
@@ -277,8 +277,13 @@ GDB:
 If you do this, then typing C-c or C-BREAK into the console window
 through which you interact with GDB will stop Emacs and return control
 to the debugger, no matter if Emacs displays GUI or text-mode frames.
-This is the only reliable alternative on MS-Windows to get control to
-the debugger, besides setting breakpoints in advance.
+With GDB versions before 13.1, this is the only reliable alternative
+on MS-Windows to get control to the debugger, besides setting
+breakpoints in advance.  GDB 13.1 changed the way C-c and C-BREAK are
+handled on Windows, so with those newer versions, you don't need the
+"set new-console 1" setting to be able to interrupt Emacs by typing
+C-c or C-BREAK into the console window from which you started Emacs
+and where you interact with GDB.
 
 ** Examining Lisp object values.
 
diff --git a/lisp/faces.el b/lisp/faces.el
index 29e26e4c65..fe683e437f 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -690,6 +690,10 @@ be reset to `unspecified' when creating new frames, 
disregarding
 what the FACE's face spec says, call this function with FRAME set to
 t and the ATTRIBUTE's value set to `unspecified'.
 
+Note that the ATTRIBUTE VALUE pairs are evaluated in the order
+they are specified, except the `:family' and `:foundry'
+attributes which are evaluated first.
+
 The following attributes are recognized:
 
 `:family'
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index a45e74eca2..bc631747e6 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -569,24 +569,29 @@ the major mode specifies support for Font Lock."
       (when (and face-before face-after (not (eq face-before face-after)))
         (setq face-before nil))
       (when (or face-after face-before)
-        (let* ((hi-text
-                (buffer-substring-no-properties
-                 (if face-before
-                     (or (previous-single-property-change (point) 'face)
-                         (point-min))
-                   (point))
-                 (if face-after
-                     (or (next-single-property-change (point) 'face)
-                         (point-max))
-                   (point)))))
+        (let* ((beg (if face-before
+                        (or (previous-single-property-change (point) 'face)
+                            (point-min))
+                      (point)))
+               (end (if face-after
+                        (or (next-single-property-change (point) 'face)
+                            (point-max))
+                      (point))))
           ;; Compute hi-lock patterns that match the
           ;; highlighted text at point.  Use this later in
           ;; during completing-read.
           (dolist (hi-lock-pattern hi-lock-interactive-patterns)
-            (let ((regexp (or (car (rassq hi-lock-pattern 
hi-lock-interactive-lighters))
-                              (car hi-lock-pattern))))
-              (if (string-match regexp hi-text)
-                  (push regexp regexps)))))))
+            (let ((pattern (or (rassq hi-lock-pattern 
hi-lock-interactive-lighters)
+                               (car hi-lock-pattern))))
+              (cond
+               ((stringp pattern)
+                (when (string-match pattern (buffer-substring-no-properties 
beg end))
+                  (push pattern regexps)))
+               ((functionp (cadr pattern))
+                (save-excursion
+                  (goto-char beg)
+                  (when (funcall (cadr pattern) end)
+                    (push (car pattern) regexps))))))))))
     regexps))
 
 (defvar-local hi-lock--unused-faces nil
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 6e42296e7b..7a720cf2c0 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1474,7 +1474,10 @@ when the buffer's text is already an exact match."
               (if (and (eq this-command last-command) completion-auto-help)
                   (minibuffer-completion-help beg end))
               (completion--done completion 'exact
-                                (unless expect-exact
+                                (unless (or expect-exact
+                                            (and completion-auto-select
+                                                 (eq this-command last-command)
+                                                 completion-auto-help))
                                   "Complete, but not unique"))))
 
             (minibuffer--bitset completed t exact))))))))
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 4e3a88bbda..2d3730e294 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -645,13 +645,26 @@ parts of the list.
 
 The OFFSET argument is added to/taken away from the index that will be
 used.  This is really only useful with `first' and `last', for
-accessing absolute argument positions."
-  (nth (+ (pcase index
-          ('first 0)
-          ('last  pcomplete-last)
-          (_      (- pcomplete-index (or index 0))))
-         (or offset 0))
-       pcomplete-args))
+accessing absolute argument positions.
+
+When the argument has been transformed into something that is not
+a string by `pcomplete-parse-arguments-function', the text
+representation of the argument, namely what the user actually
+typed in, is returned, and the value of the argument is stored in
+the pcomplete-arg-value text property of that string."
+  (let ((arg
+         (nth (+ (pcase index
+                  ('first 0)
+                  ('last  pcomplete-last)
+                  (_      (- pcomplete-index (or index 0))))
+                (or offset 0))
+              pcomplete-args)))
+    (if (stringp arg)
+        arg
+      (propertize
+       (buffer-substring (pcomplete-begin index offset)
+                         (pcomplete-begin (1- (or index 0)) offset))
+       'pcomplete-arg-value arg))))
 
 (defun pcomplete-begin (&optional index offset)
   "Return the beginning position of the INDEXth argument.
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 12e021bc67..50b951888a 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -118,7 +118,7 @@ MODE is either `c' or `cpp'."
          `(((parent-is "translation_unit") parent-bol 0)
            ((node-is ")") parent 1)
            ((node-is "]") parent-bol 0)
-           ((node-is "}") (and parent parent-bol) 0)
+           ((node-is "}") c-ts-mode--bracket-children-anchor 0)
            ((node-is "else") parent-bol 0)
            ((node-is "case") parent-bol 0)
            ((node-is "preproc_arg") no-indent)
@@ -133,7 +133,8 @@ MODE is either `c' or `cpp'."
            ((match "#endif" "preproc_if") point-min 0)
            ((match "preproc_function_def" "compound_statement") point-min 0)
            ((match "preproc_call" "compound_statement") point-min 0)
-           ((parent-is "compound_statement") (and parent parent-bol) 
c-ts-mode-indent-offset)
+           ((parent-is "compound_statement")
+            c-ts-mode--bracket-children-anchor c-ts-mode-indent-offset)
            ((parent-is "function_definition") parent-bol 0)
            ((parent-is "conditional_expression") first-sibling 0)
            ((parent-is "assignment_expression") parent-bol 
c-ts-mode-indent-offset)
@@ -189,6 +190,21 @@ MODE is either `c' or `cpp'."
              ('linux (alist-get 'linux (c-ts-mode--indent-styles mode)))))))
     `((,mode ,@style))))
 
+(defun c-ts-mode--bracket-children-anchor (_n parent &rest _)
+  "This anchor is used for children of a compound_statement.
+So anything inside a {} block.  PARENT should be the
+compound_statement.  This anchor looks at the {, if itson its own
+line, anchor at it, if it has stuff before it, anchor at the
+beginning of grandparent."
+  (save-excursion
+    (goto-char (treesit-node-start parent))
+    (let ((bol (line-beginning-position)))
+      (skip-chars-backward " \t")
+      (treesit-node-start
+       (if (< bol (point))
+           (treesit-node-parent parent)
+         parent)))))
+
 (defun c-ts-mode--looking-at-star (&rest _)
   "A tree-sitter simple indent matcher.
 Matches if there is a \"*\" after point (ignoring whitespace in
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 79b7e74ec4..9c26c52df9 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -74,6 +74,8 @@
 (declare-function treesit-node-start "treesit.c")
 (declare-function treesit-node-end "treesit.c")
 (declare-function treesit-node-type "treesit.c")
+(declare-function treesit-query-compile "treesit.c")
+(declare-function treesit-query-capture "treesit.c")
 
 ;;; Constants
 
@@ -3642,8 +3644,9 @@ OVERRIDE is the override flag described in
               "call_expression")))
 
 (defvar js--treesit-lhs-identifier-query
-  (treesit-query-compile 'javascript '((identifier) @id
-                                       (property_identifier) @id))
+  (when (treesit-available-p)
+    (treesit-query-compile 'javascript '((identifier) @id
+                                         (property_identifier) @id)))
   "Query that captures identifier and query_identifier.")
 
 (defun js--treesit-fontify-assignment-lhs (node override start end &rest _)
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index f4b557f443..2390974288 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1822,8 +1822,9 @@ Initialized by `bibtex-set-dialect'.")
      1 '(11))))
 
 (defvar bibtex-font-lock-keywords
-  ;; entry type and reference key
-  `((,bibtex-any-entry-maybe-empty-head
+  `(("\\$[^$\n]+\\$" . font-lock-string-face) ; bug#50202
+    ;; entry type and reference key
+    (,bibtex-any-entry-maybe-empty-head
      (,bibtex-type-in-head font-lock-function-name-face)
      (,bibtex-key-in-head font-lock-constant-face nil t))
     ;; optional field names (treated as comments)
@@ -3631,8 +3632,11 @@ if that value is non-nil.
   (setq-local fill-paragraph-function #'bibtex-fill-field)
   (setq-local font-lock-defaults
               '(bibtex-font-lock-keywords
-                nil t ((?$ . "\"")
-                       ;; Mathematical expressions should be fontified as 
strings
+                nil t ((?$ . ".")
+                       ;; Mathematical expressions should be fontified
+                       ;; as strings.  Yet `$' may also appear in certain
+                       ;; fields like `URL' when it does not delimit
+                       ;; a math expression (bug#50202).
                        (?\" . ".")
                        ;; Quotes are field delimiters and quote-delimited
                        ;; entries should be fontified in the same way as
@@ -4079,11 +4083,19 @@ INIT is surrounded by field delimiters, unless NODELIM 
is non-nil."
 If inside an entry, move to the beginning of it, otherwise move to the
 beginning of the previous entry.  If point is ahead of all BibTeX entries
 move point to the beginning of buffer.  Return the new location of point."
+  ;; This command is similar to `beginning-of-defun', but with historical
+  ;; differences.
+  ;; - It does not move point to the previous entry if point is already
+  ;;   at the beginning of an entry
+  ;; - It does not take an optional ARG that moves backward to the beginning
+  ;;   of a defun ARG times.
+  ;; - It returns point and the code relies on this.
   (interactive)
-  (skip-chars-forward " \t")
-  (if (looking-at "@")
-      (forward-char))
-  (re-search-backward "^[ \t]*@" nil 'move)
+  (beginning-of-line)
+  ;; `bibtex-any-valid-entry-type' would fail if users "disable"
+  ;; an entry by chosing an invalid entry type.
+  (or (looking-at bibtex-any-entry-maybe-empty-head)
+      (re-search-backward bibtex-any-entry-maybe-empty-head nil 'move))
   (point))
 
 (defun bibtex-end-of-entry ()
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 204331ec72..e8d9725948 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1804,11 +1804,15 @@ can also be used to fill comments.
   :syntax-table css-mode-syntax-table
   (when (treesit-ready-p 'css)
     ;; Borrowed from `css-mode'.
+    (setq-local syntax-propertize-function
+                css-syntax-propertize-function)
     (add-hook 'completion-at-point-functions
               #'css-completion-at-point nil 'local)
     (setq-local fill-paragraph-function #'css-fill-paragraph)
     (setq-local adaptive-fill-function #'css-adaptive-fill)
-    (setq-local add-log-current-defun-function #'css-current-defun-name)
+    ;; `css--fontify-region' first calls the default function, which
+    ;; will call tree-sitter's function, then it fontifies colors.
+    (setq-local font-lock-fontify-region-function #'css--fontify-region)
 
     ;; Tree-sitter specific setup.
     (treesit-parser-create 'css)
@@ -1821,8 +1825,8 @@ can also be used to fill comments.
                   (property constant string)
                   (error variable function operator bracket)))
     (setq-local treesit-simple-imenu-settings
-                `( nil ,(rx bos (or "rule_set" "media_statement") eos)
-                   nil nil))
+                `(( nil ,(rx bos (or "rule_set" "media_statement") eos)
+                    nil nil)))
     (treesit-major-mode-setup)))
 
 ;;;###autoload
diff --git a/lisp/treesit.el b/lisp/treesit.el
index f8c87c35aa..4af555fb8e 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1779,13 +1779,17 @@ comments and multiline string literals.  For example,
 This function tries to move to the beginning of a line, either by
 moving to the empty newline after a defun, or to the beginning of
 the current line if the beginning of the defun is indented."
-  (cond ((and (looking-at (rx (* (or " " "\\t")) "\n"))
-              (not (looking-at (rx bol))))
-         (goto-char (match-end 0)))
-        ((save-excursion
-           (skip-chars-backward " \t")
-           (eq (point) (line-beginning-position)))
-         (goto-char (line-beginning-position)))))
+  ;; Moving forward, point at the end of a line and not already on an
+  ;; empty line: go to BOL of the next line (which hopefully is an
+  ;; empty line).
+  (cond ((and (looking-at (rx (* (or " " "\t")) "\n"))
+              (not (bolp)))
+         (forward-line 1))
+        ;; Moving backward, but there are some whitespace (and only
+        ;; whitespace) between point and BOL: go back to BOL.
+        ((looking-back (rx (+ (or " " "\t")))
+                       (line-beginning-position))
+         (beginning-of-line))))
 
 ;; prev-sibling:
 ;; 1. end-of-node before pos
diff --git a/src/keyboard.c b/src/keyboard.c
index d68b50428a..7bf89ac7d4 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -503,11 +503,10 @@ echo_add_key (Lisp_Object c)
   if ((NILP (echo_string) || SCHARS (echo_string) == 0)
       && help_char_p (c))
     {
-      AUTO_STRING (str, " (Type ? for further options, q for quick help)");
+      AUTO_STRING (str, " (Type ? for further options, C-q for quick help)");
       AUTO_LIST2 (props, Qface, Qhelp_key_binding);
       Fadd_text_properties (make_fixnum (7), make_fixnum (8), props, str);
-      Fadd_text_properties (make_fixnum (30), make_fixnum (31), props,
-str);
+      Fadd_text_properties (make_fixnum (30), make_fixnum (33), props, str);
       new_string = concat2 (new_string, str);
     }
 
diff --git a/src/treesit.c b/src/treesit.c
index 6570ada1d9..eaa563a54c 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -2070,12 +2070,11 @@ Note that this function returns an immediate child, not 
the smallest
 
   struct buffer *buf = XBUFFER (XTS_PARSER (XTS_NODE (node)->parser)->buffer);
   ptrdiff_t visible_beg = XTS_PARSER (XTS_NODE (node)->parser)->visible_beg;
-  ptrdiff_t byte_pos = buf_charpos_to_bytepos (buf, XFIXNUM (pos));
 
   treesit_check_position (pos, buf);
-
   treesit_initialize ();
 
+  ptrdiff_t byte_pos = buf_charpos_to_bytepos (buf, XFIXNUM (pos));
   TSNode treesit_node = XTS_NODE (node)->node;
   TSNode child;
   if (NILP (named))
@@ -2106,14 +2105,14 @@ If NODE is nil, return nil.  */)
 
   struct buffer *buf = XBUFFER (XTS_PARSER (XTS_NODE (node)->parser)->buffer);
   ptrdiff_t visible_beg = XTS_PARSER (XTS_NODE (node)->parser)->visible_beg;
-  ptrdiff_t byte_beg = buf_charpos_to_bytepos (buf, XFIXNUM (beg));
-  ptrdiff_t byte_end = buf_charpos_to_bytepos (buf, XFIXNUM (end));
 
   treesit_check_position (beg, buf);
   treesit_check_position (end, buf);
 
   treesit_initialize ();
 
+  ptrdiff_t byte_beg = buf_charpos_to_bytepos (buf, XFIXNUM (beg));
+  ptrdiff_t byte_end = buf_charpos_to_bytepos (buf, XFIXNUM (end));
   TSNode treesit_node = XTS_NODE (node)->node;
   TSNode child;
   if (NILP (named))
diff --git a/test/lisp/whitespace-tests.el b/test/lisp/whitespace-tests.el
index 12f6cb99a2..d72748cd0c 100644
--- a/test/lisp/whitespace-tests.el
+++ b/test/lisp/whitespace-tests.el
@@ -42,13 +42,6 @@ nil, `whitespace-mode' is left disabled."
           '(whitespace-mode 1))
        ,@body)))
 
-(defmacro whitespace--with-buffer-selected (buffer-or-name &rest body)
-  (declare (debug (form body)) (indent 1))
-  `(save-window-excursion
-     (with-current-buffer (or ,buffer-or-name (current-buffer))
-       (with-selected-window (display-buffer (current-buffer))
-         ,@body))))
-
 (defun whitespace-tests--faceup (&rest lines)
   "Convenience wrapper around `faceup-test-font-lock-buffer'.
 Returns non-nil if the concatenated LINES match the current
@@ -354,7 +347,7 @@ buffer's content."
           (indirect (clone-indirect-buffer (buffer-name) nil)))
       (should (eq (marker-buffer whitespace-bob-marker) base))
       (should (eq (marker-buffer whitespace-eob-marker) base))
-      (whitespace--with-buffer-selected indirect
+      (ert-with-buffer-selected indirect
         ;; Mutate the indirect buffer to update its bob/eob markers.
         (execute-kbd-macro (kbd "z RET M-< a")))
       ;; With Bug#59618, the above mutation would cause the base
@@ -382,7 +375,7 @@ buffer's content."
           ;; because the buffer should only be killed on success.
           (indirect (clone-indirect-buffer nil nil)))
       (whitespace-tests--check-markers base 2 4)
-      (whitespace--with-buffer-selected indirect
+      (ert-with-buffer-selected indirect
         (whitespace-tests--check-markers indirect 2 4)
         ;; Mutate the buffer to trigger `after-change-functions' and
         ;; thus `whitespace--update-bob-eob'.
@@ -405,7 +398,7 @@ buffer's content."
           ;; the buffer should only be killed on success.
           (clone (clone-buffer)))
       (whitespace-tests--check-markers orig 2 4)
-      (whitespace--with-buffer-selected clone
+      (ert-with-buffer-selected clone
         (whitespace-tests--check-markers clone 2 4)
         (execute-kbd-macro (kbd "z RET M-< a"))
         (whitespace-tests--check-markers clone 1 8))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]