From 7ef9a8210c9b6c2adf6094d8e85a50edd91e54e3 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 1 Mar 2023 14:28:04 +0800 Subject: [PATCH 01/18] Replace C++ comments with C style equivalents * src/alloc.c (Fmake_byte_code, purecopy): * src/bytecode.c (exec_byte_code): * src/xdisp.c (face_at_pos): Do not use C++-style comments! --- src/alloc.c | 5 +++-- src/bytecode.c | 4 ++-- src/xdisp.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index f7a0a4a80c8..05a19f0b7e9 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3542,7 +3542,8 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT && FIXNATP (args[COMPILED_STACK_DEPTH]))) error ("Invalid byte-code object"); - pin_string (args[COMPILED_BYTECODE]); // Bytecode must be immovable. + /* Bytecode must be immovable. */ + pin_string (args[COMPILED_BYTECODE]); /* We used to purecopy everything here, if purify-flag was set. This worked OK for Emacs-23, but with Emacs-24's lexical binding code, it can be @@ -5687,7 +5688,7 @@ purecopy (Lisp_Object obj) memcpy (vec, objp, nbytes); for (i = 0; i < size; i++) vec->contents[i] = purecopy (vec->contents[i]); - // Byte code strings must be pinned. + /* Byte code strings must be pinned. */ if (COMPILEDP (obj) && size >= 2 && STRINGP (vec->contents[1]) && !STRING_MULTIBYTE (vec->contents[1])) pin_string (vec->contents[1]); diff --git a/src/bytecode.c b/src/bytecode.c index 124348e5b35..74a94859aba 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -789,10 +789,10 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template, Lisp_Object template; Lisp_Object bytecode; if (COMPILEDP (call_fun) - // Lexical binding only. + /* Lexical binding only. */ && (template = AREF (call_fun, COMPILED_ARGLIST), FIXNUMP (template)) - // No autoloads. + /* No autoloads. */ && (bytecode = AREF (call_fun, COMPILED_BYTECODE), !CONSP (bytecode))) { diff --git a/src/xdisp.c b/src/xdisp.c index b64f1d35cbc..6219bb9ec6e 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4583,7 +4583,7 @@ face_at_pos (const struct it *it, enum lface_attribute_index attr_filter) &next_stop, base_face_id, false, attr_filter); - } // !STRINGP (it->string)) + } /* !STRINGP (it->string) */ } From 4a6db125b9ee5d681aa09d86c9283526f204b274 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Tue, 28 Feb 2023 23:51:06 -0800 Subject: [PATCH 02/18] Fix treesit-indent-region Fix it for the case where there is no suitable rule for the line. Right now treesit-indent-region would indent the line to column 0. After the change the indentation is not altered. * lisp/treesit.el (treesit-indent-region): Handle the case where ANCHOR or OFFSET is nil specially. --- lisp/treesit.el | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 052f641abfd..fe9ed399773 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1532,14 +1532,24 @@ Similar to `treesit-indent', but indent a region instead." (aref meta-vec (+ 1 (* idx meta-len))) nil) (pcase-let* ((`(,anchor . ,offset) (treesit--indent-1)) (marker (aref meta-vec (* idx meta-len)))) - ;; Set ANCHOR. - (when anchor + (if (not (and anchor offset)) + ;; No indent for this line, either... + (if (markerp marker) + (progn + ;; ... Set marker and offset to do a dummy + ;; indent, or... + (back-to-indentation) + (move-marker marker (point)) + (setf (aref meta-vec (+ 1 (* idx meta-len))) 0)) + ;; ...Set anchor to nil so no indent is performed. + (setf (aref meta-vec (* idx meta-len)) nil)) + ;; Set ANCHOR. (if (markerp marker) (move-marker marker anchor) (setf (aref meta-vec (* idx meta-len)) - (copy-marker anchor t)))) - ;; SET OFFSET. - (setf (aref meta-vec (+ 1 (* idx meta-len))) offset))) + (copy-marker anchor t))) + ;; SET OFFSET. + (setf (aref meta-vec (+ 1 (* idx meta-len))) offset)))) (cl-incf idx) (setq lines-left-to-move (forward-line 1))) ;; Now IDX = last valid IDX + 1. From 40c9fc8e3b3f55c9122b95e21660b5709109bd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 1 Mar 2023 11:12:51 +0000 Subject: [PATCH 03/18] Eglot: work around Tramp instability bug#61350 Unconditionally disable ControlMaster for the Eglot's Tramp connection. * lisp/progmodes/eglot.el (tramp-ssh-controlmaster-options) (use-tramp-ssh-controlmaster-options): Forward declare (eglot--connect): Set variables to unconditionally disable ControlMaster. --- lisp/progmodes/eglot.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 40fc8f8a12f..119b4f64c8d 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -130,7 +130,8 @@ (defvar markdown-fontify-code-blocks-natively) (defvar company-backends) (defvar company-tooltip-align-annotations) - +(defvar tramp-ssh-controlmaster-options) +(defvar tramp-use-ssh-controlmaster-options) ;;; User tweakable stuff @@ -1249,7 +1250,15 @@ This docstring appeases checkdoc, that's all." (contact (cl-subseq contact 0 probe))) `(:process ,(lambda () - (let ((default-directory default-directory)) + (let ((default-directory default-directory) + ;; bug#61350: Tramp turns on a feature + ;; by default that can't (yet) handle + ;; very much data so we turn it off + ;; unconditionally -- just for our + ;; process. + (tramp-use-ssh-controlmaster-options t) + (tramp-ssh-controlmaster-options + "-o ControlMaster=no -o ControlPath=none")) (make-process :name readable-name :command (setq server-info (eglot--cmd contact)) From 0a4b1c0102d4062d24e19340f863b9df25e07ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 1 Mar 2023 13:24:07 +0000 Subject: [PATCH 04/18] ; Eglot: improve bug-reference-url-format/bug-reference-url-regexp * lisp/progmodes/eglot.el (eglot--debbugs-or-github-bug-uri): New helper. --- lisp/progmodes/eglot.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 119b4f64c8d..36aafac8938 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3661,6 +3661,15 @@ If NOERROR, return predicate, else erroring function." (with-eval-after-load 'desktop (add-to-list 'desktop-minor-mode-handlers '(eglot--managed-mode . ignore))) + +;;; Misc +;;; +(defun eglot--debbugs-or-github-bug-uri () + (format (if (string= (match-string 2) "github") + "https://github.com/joaotavora/eglot/issues/%s" + "https://debbugs.gnu.org/%s") + (match-string 3))) +(put 'eglot--debbugs-or-github-bug-uri 'bug-reference-url-format t) ;;; Obsolete ;;; @@ -3671,8 +3680,8 @@ If NOERROR, return predicate, else erroring function." ;; Local Variables: -;; bug-reference-bug-regexp: "\\(github#\\([0-9]+\\)\\)" -;; bug-reference-url-format: "https://github.com/joaotavora/eglot/issues/%s" +;; bug-reference-bug-regexp: "\\(\\(github\\|bug\\)#\\([0-9]+\\)\\)" +;; bug-reference-url-format: eglot--debbugs-or-github-bug-uri ;; checkdoc-force-docstrings-flag: nil ;; End: From 99df815c153265706edc839b7467fb3ae3b6e1b1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 1 Mar 2023 17:35:51 +0200 Subject: [PATCH 05/18] Revert "Don't disable eldoc when doing edebug" This reverts commit 6fd1fb8a6837acde8e1c9ab26618ec0f36121c72. It turns out ElDoc does show messages inside Edebug, if you are (un)lucky enough to have point where ElDoc has something to show. Bug#56459 needs to be fixed in some more complex way. --- lisp/emacs-lisp/eldoc.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 83948ad00d4..a175edcc671 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -388,6 +388,7 @@ Also store it in `eldoc-last-message' and return that value." (defun eldoc-display-message-no-interference-p () "Return nil if displaying a message would cause interference." (not (or executing-kbd-macro + (bound-and-true-p edebug-active) ;; The following configuration shows "Matches..." in the ;; echo area when point is after a closing bracket, which ;; conflicts with eldoc. From 1f1d36fa8080479083af8c69e8ea3756d51910fb Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 1 Mar 2023 12:31:09 -0500 Subject: [PATCH 06/18] * lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Fix bug#61847 The `noerror` arg of `require` doesn't do what Stefan naively thought when he wrote this code, so use `condition-case` instead. Also check for `cl-defmethod` since `cl-prin1` can't be loaded before that anyway. --- lisp/emacs-lisp/debug-early.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/debug-early.el b/lisp/emacs-lisp/debug-early.el index 395498f2206..e393daee879 100644 --- a/lisp/emacs-lisp/debug-early.el +++ b/lisp/emacs-lisp/debug-early.el @@ -46,10 +46,10 @@ of the build process." (print-escape-control-characters t) (print-escape-nonascii t) (prin1 (if (and (fboundp 'cl-prin1) - ;; If we're being called while - ;; bootstrapping, we won't be able to load - ;; cl-print. - (require 'cl-print nil t)) + (fboundp 'cl-defmethod) ;Used by `cl-print'. + (condition-case nil + (require 'cl-print) + (error nil))) #'cl-prin1 #'prin1))) (mapbacktrace From 07f3236133b01cb65806eb1a6bf2ebaecbdd2d81 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 1 Mar 2023 12:36:58 -0500 Subject: [PATCH 07/18] * src/profiler.c (malloc_probe): Make it safe for GC (bug#60237) --- src/profiler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/profiler.c b/src/profiler.c index 81b5e7b0cf0..8247b2e90c6 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -505,6 +505,9 @@ Before returning, a new log is allocated for future samples. */) void malloc_probe (size_t size) { + if (EQ (backtrace_top_function (), QAutomatic_GC)) /* bug#60237 */ + /* FIXME: We should do something like what we did with `cpu_gc_count`. */ + return; eassert (HASH_TABLE_P (memory_log)); record_backtrace (XHASH_TABLE (memory_log), min (size, MOST_POSITIVE_FIXNUM)); } From ef72e99e867e76135644de6ba29c8d423c5a00ae Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 27 Feb 2023 20:32:53 +0200 Subject: [PATCH 08/18] * lisp/icomplete.el: Fix in-buffer completion. (icomplete-force-complete-and-exit, icomplete-force-complete): Use 'icomplete--field-beg/end' when not in the minibuffer to not erase the current buffer. Also disable 'completion-in-region-mode' instead of calling 'exit-minibuffer' (bug#45764, bug#51575, bug#61479). Backport: (cherry picked from commit a7a984c0ebebb891e2052d8416544f0bd7002007) --- lisp/icomplete.el | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 014f38b2024..fd6a09e8702 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -215,15 +215,29 @@ the default otherwise." ;; calculated, This causes the first cached completion to ;; be taken (i.e. the one that the user sees highlighted) completion-all-sorted-completions) - (minibuffer-force-complete-and-exit) + (if (window-minibuffer-p) + (minibuffer-force-complete-and-exit) + (minibuffer-force-complete (icomplete--field-beg) + (icomplete--field-end) + 'dont-cycle) + (completion-in-region-mode -1)) ;; Otherwise take the faster route... - (minibuffer-complete-and-exit))) + (if (window-minibuffer-p) + (minibuffer-complete-and-exit) + (completion-complete-and-exit + (icomplete--field-beg) + (icomplete--field-end) + (lambda () (completion-in-region-mode -1)))))) (defun icomplete-force-complete () "Complete the icomplete minibuffer." (interactive) ;; We're not at all interested in cycling here (bug#34077). - (minibuffer-force-complete nil nil 'dont-cycle)) + (if (window-minibuffer-p) + (minibuffer-force-complete nil nil 'dont-cycle) + (minibuffer-force-complete (icomplete--field-beg) + (icomplete--field-end) + 'dont-cycle))) ;; Apropos `icomplete-scroll', we implement "scrolling icomplete" ;; within classic icomplete, which is "rotating", by contrast. From db50545e3e9cd51dd8e6ad93034dc48d45b705e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 27 Feb 2023 20:40:48 +0200 Subject: [PATCH 09/18] * lisp/icomplete.el (fido-mode): Enable in-buffer completion (bug#45763). Backport: (cherry picked from commit b5c13032538377b0037c745715613693a1580f81) --- lisp/icomplete.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index fd6a09e8702..0adb0e5afeb 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -443,9 +443,12 @@ more like `ido-mode' than regular `icomplete-mode'." :global t (remove-hook 'minibuffer-setup-hook #'icomplete-minibuffer-setup) (remove-hook 'minibuffer-setup-hook #'icomplete--fido-mode-setup) + (remove-hook 'completion-in-region-mode-hook #'icomplete--in-region-setup) (when fido-mode (icomplete-mode -1) (setq icomplete-mode t) + (when icomplete-in-buffer + (add-hook 'completion-in-region-mode-hook #'icomplete--in-region-setup)) (add-hook 'minibuffer-setup-hook #'icomplete-minibuffer-setup) (add-hook 'minibuffer-setup-hook #'icomplete--fido-mode-setup))) From 6b2720778dc9531c0157bc7e773d2011bdf905e3 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 1 Mar 2023 13:55:53 -0800 Subject: [PATCH 10/18] Improve tree-sitter's prev-sibling indent anchor Now it handles the case where NODE is nil when indenting an empty line: it tries to get the previous sibling nonetheless. * lisp/progmodes/c-ts-mode.el (c-ts-mode--anchor-prev-sibling): * lisp/treesit.el (treesit-simple-indent-presets): Add an or form to handle more cases. --- lisp/progmodes/c-ts-mode.el | 12 +++++++++--- lisp/treesit.el | 12 ++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 53f7839e4af..cc99b8e213e 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -257,7 +257,7 @@ is actually the parent of point at the moment of indentation." 0 c-ts-mode-indent-offset))) -(defun c-ts-mode--anchor-prev-sibling (node &rest _) +(defun c-ts-mode--anchor-prev-sibling (node parent bol &rest _) "Return the start of the previous named sibling of NODE. This anchor handles the special case where the previous sibling @@ -273,8 +273,14 @@ The anchor of \"int y = 2;\" should be \"int x = 1;\" rather than the labeled_statement. Return nil if a) there is no prev-sibling, or 2) prev-sibling -doesn't have a child." - (when-let ((prev-sibling (treesit-node-prev-sibling node t))) +doesn't have a child. + +PARENT and BOL are like other anchor functions." + (when-let ((prev-sibling + (or (treesit-node-prev-sibling node t) + (treesit-node-prev-sibling + (treesit-node-first-child-for-pos parent bol) t) + (treesit-node-child parent -1 t)))) (while (and prev-sibling (equal "labeled_statement" (treesit-node-type prev-sibling))) diff --git a/lisp/treesit.el b/lisp/treesit.el index fe9ed399773..dbd102d00b3 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1237,9 +1237,17 @@ See `treesit-simple-indent-presets'.") (line-beginning-position)) (throw 'term (point))) (setq parent (treesit-node-parent parent))))))) - (cons 'prev-sibling (lambda (node &rest _) + (cons 'prev-sibling (lambda (node parent bol &rest _) (treesit-node-start - (treesit-node-prev-sibling node)))) + (or (treesit-node-prev-sibling node t) + ;; If node is nil (indenting empty + ;; line), we still try to guess the + ;; previous sibling. + (treesit-node-prev-sibling + (treesit-node-first-child-for-pos + parent bol) + t) + (treesit-node-child parent -1 t))))) (cons 'no-indent (lambda (_n _p bol &rest _) bol)) (cons 'prev-line (lambda (_n _p bol &rest _) (save-excursion From b06d5519664b0f417be7f415964b0a4decc0f732 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 1 Mar 2023 14:01:47 -0800 Subject: [PATCH 11/18] Fix c-ts-mode empty line indentation (bug#61893) * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Make the "rest sibling" matchers catch the case where NODE is nil, when indenting an empty line. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test. --- lisp/progmodes/c-ts-mode.el | 8 ++--- .../progmodes/c-ts-mode-resources/indent.erts | 33 ++++++++++++++----- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index cc99b8e213e..259b96d342e 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -356,17 +356,17 @@ MODE is either `c' or `cpp'." ;; int[5] a = { 0, 0, 0, 0 }; ((match nil "initializer_list" nil 1 1) parent-bol c-ts-mode-indent-offset) - ((match nil "initializer_list" nil 2) c-ts-mode--anchor-prev-sibling 0) + ((parent-is "initializer_list") c-ts-mode--anchor-prev-sibling 0) ;; Statement in enum. ((match nil "enumerator_list" nil 1 1) standalone-parent c-ts-mode-indent-offset) - ((match nil "enumerator_list" nil 2) c-ts-mode--anchor-prev-sibling 0) + ((parent-is "enumerator_list") c-ts-mode--anchor-prev-sibling 0) ;; Statement in struct and union. ((match nil "field_declaration_list" nil 1 1) standalone-parent c-ts-mode-indent-offset) - ((match nil "field_declaration_list" nil 2) c-ts-mode--anchor-prev-sibling 0) + ((parent-is "field_declaration_list") c-ts-mode--anchor-prev-sibling 0) ;; Statement in {} blocks. ((match nil "compound_statement" nil 1 1) standalone-parent c-ts-mode-indent-offset) - ((match nil "compound_statement" nil 2) c-ts-mode--anchor-prev-sibling 0) + ((parent-is "compound_statement") c-ts-mode--anchor-prev-sibling 0) ;; Opening bracket. ((node-is "compound_statement") standalone-parent c-ts-mode-indent-offset) ;; Bug#61291. diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts index 36d7af4faf1..904c6498cb5 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts @@ -84,14 +84,6 @@ int main() } =-=-= -Name: Empty Line -=-= -int main() -{ - | -} -=-=-= - Name: Concecutive blocks (GNU Style) (bug#60873) =-= @@ -385,3 +377,28 @@ namespace test { }; } =-=-= + +Code: + (lambda () + (c-ts-mode) + (setq-local indent-tabs-mode nil) + (setq-local c-ts-mode-indent-offset 2) + (c-ts-mode-set-style 'gnu) + (indent-for-tab-command)) + +Name: Empty Line +=-= +int main() +{ + | +} +=-=-= + +Name: Empty Line Previous Sibling +=-= +int main() +{ + int a = 1; + | +} +=-=-= From 56cd810b9d1a4d537bee5a2fd954d6e0d346631a Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 1 Mar 2023 14:34:56 -0800 Subject: [PATCH 12/18] =?UTF-8?q?Don=E2=80=99t=20signal=20warning=20when?= =?UTF-8?q?=20loading=20go-ts-mode.el=20without=20grammar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/progmodes/go-ts-mode.el: Add a QUIET flag to the call of treesit-ready-p, so that it doesn't signal a warning if go-mod (tree-sitter grammar) is not available. --- lisp/progmodes/go-ts-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index e8f93d14744..6043c86ac93 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -393,7 +393,7 @@ what the parent of the node would be if it were a node." (treesit-major-mode-setup))) -(if (treesit-ready-p 'gomod) +(if (treesit-ready-p 'gomod t) (add-to-list 'auto-mode-alist '("/go\\.mod\\'" . go-mod-ts-mode))) (provide 'go-ts-mode) From 59365f928565f1be551b1697b9246b00cb87a9b7 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 1 Mar 2023 14:38:22 -0800 Subject: [PATCH 13/18] * lisp/progmodes/go-ts-mode.el: Use treesit-language-available-p. treesit-ready-p does more checks than language grammar availability. --- lisp/progmodes/go-ts-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index 6043c86ac93..fbe085a2c6c 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -393,7 +393,7 @@ what the parent of the node would be if it were a node." (treesit-major-mode-setup))) -(if (treesit-ready-p 'gomod t) +(if (treesit-language-available-p 'gomod) (add-to-list 'auto-mode-alist '("/go\\.mod\\'" . go-mod-ts-mode))) (provide 'go-ts-mode) From a1cb77771a29b97ac3a256322129d12368ec4e4b Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 2 Mar 2023 03:07:37 +0000 Subject: [PATCH 14/18] ; * src/haikufont.c (haikufont_open): Remove unused variable. --- src/haikufont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/haikufont.c b/src/haikufont.c index a025dec58bb..b4c2e547247 100644 --- a/src/haikufont.c +++ b/src/haikufont.c @@ -760,7 +760,7 @@ haikufont_open (struct frame *f, Lisp_Object font_entity, int pixel_size) struct haiku_font_pattern ptn; struct font *font; void *be_font; - Lisp_Object font_object, tem, extra, indices, antialias; + Lisp_Object font_object, extra, indices, antialias; int px_size, min_width, max_width; int avg_width, height, space_width, ascent; int descent, underline_pos, underline_thickness; From 30e2a85717c4189994c7ae759888e257225f0a21 Mon Sep 17 00:00:00 2001 From: Philippe Altherr Date: Sat, 14 Jan 2023 05:22:26 +0100 Subject: [PATCH 15/18] Use 'sh-indent-for-continuation' for continued lines in 'sh-script-mode' * lisp/progmodes/sh-script.el (sh-smie--indent-continuation): Use 'sh-indent-for-continuation' instead of 'sh-basic-offset'. (Bug#60832) * test/lisp/progmodes/sh-script-tests.el (test-indent-after-continuation): New test. --- lisp/progmodes/sh-script.el | 7 +++++-- test/lisp/progmodes/sh-script-tests.el | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 17c22ff4751..741803a5175 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -2010,7 +2010,7 @@ May return nil if the line should not be treated as continued." (forward-line -1) (if (sh-smie--looking-back-at-continuation-p) (current-indentation) - (+ (current-indentation) sh-basic-offset)))) + (+ (current-indentation) (sh-var-value 'sh-indent-for-continuation))))) (t ;; Just make sure a line-continuation is indented deeper. (save-excursion @@ -2031,7 +2031,10 @@ May return nil if the line should not be treated as continued." ;; check the line before that one. (> ci indent)) (t ;Previous line is the beginning of the continued line. - (setq indent (min (+ ci sh-basic-offset) max)) + (setq + indent + (min + (+ ci (sh-var-value 'sh-indent-for-continuation)) max)) nil))))) indent)))))) diff --git a/test/lisp/progmodes/sh-script-tests.el b/test/lisp/progmodes/sh-script-tests.el index c850a5d8af7..52c1303c414 100644 --- a/test/lisp/progmodes/sh-script-tests.el +++ b/test/lisp/progmodes/sh-script-tests.el @@ -52,6 +52,24 @@ (ert-deftest test-indentation () (ert-test-erts-file (ert-resource-file "sh-indents.erts"))) +(ert-deftest test-indent-after-continuation () + (with-temp-buffer + (insert "for f \\\nin a; do \\\ntoto; \\\ndone\n") + (shell-script-mode) + (let ((sh-indent-for-continuation '++)) + (let ((sh-indent-after-continuation t)) + (indent-region (point-min) (point-max)) + (should (equal (buffer-string) + "for f \\\n\tin a; do \\\n toto; \\\n done\n"))) + (let ((sh-indent-after-continuation 'always)) + (indent-region (point-min) (point-max)) + (should (equal (buffer-string) + "for f \\\n\tin a; do \\\n\ttoto; \\\n\tdone\n"))) + (let ((sh-indent-after-continuation nil)) + (indent-region (point-min) (point-max)) + (should (equal (buffer-string) + "for f \\\nin a; do \\\n toto; \\\ndone\n")))))) + (defun test-sh-back (string &optional pos) (with-temp-buffer (shell-script-mode) From 68f49083af7ac5ffd9cde4bc7167d4e2ccbba4b6 Mon Sep 17 00:00:00 2001 From: Philippe Altherr Date: Sun, 15 Jan 2023 13:37:00 +0100 Subject: [PATCH 16/18] Add support for Zsh's case branches ;|. * lisp/progmodes/sh-script.el (sh-font-lock-paren) (sh-smie-sh-grammar, sh-smie-sh-rules, sh-smie-rc-grammar): Support case branches ending with ";|", per Zsh. (Bug#60833) * test/manual/indent/shell.sh (bar): Add ";|". --- lisp/progmodes/sh-script.el | 18 +++++++++++------- test/manual/indent/shell.sh | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 741803a5175..398a2c8946b 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -1042,7 +1042,9 @@ subshells can nest." ;; Maybe we've bumped into an escaped newline. (sh-is-quoted-p (point))) (backward-char 1)) - (when (eq (char-before) ?|) + (when (and + (eq (char-before) ?|) + (not (eq (char-before (1- (point))) ?\;))) (backward-char 1) t))) (and (> (point) (1+ (point-min))) (progn (backward-char 2) @@ -1053,7 +1055,7 @@ subshells can nest." ;; a normal command rather than the real `in' keyword. ;; I.e. we should look back to try and find the ;; corresponding `case'. - (and (looking-at ";[;&]\\|\\_ Date: Thu, 10 Mar 2022 08:36:04 +0000 Subject: [PATCH 17/18] Add new user option Man-prefer-synchronous-call * lisp/man.el (Man-getpage-in-background): Add new defcustom Man-prefer-synchronous-call and modify #'Man-getpage-in-background. Only call #'start-process when 'make-process satisfies #'fboundp AND Man-prefer-synchronous-call is bound to nil. (Bug#61552) Copyright-paperwork-exempt: yes --- doc/emacs/programs.texi | 6 ++++++ etc/NEWS | 7 +++++++ lisp/man.el | 11 ++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index d97bd56be21..c6c67047c43 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -1387,6 +1387,12 @@ this, change the value of the variable @code{Man-switches} to @kbd{M-p} to switch between man pages in different sections. The mode line shows how many manual pages are available. +@vindex Man-prefer-synchronous-call + By default, @kbd{M-x man} calls the @code{man} program +asynchronously. If you would prefer it if @kbd{M-x man} called the +@code{man} program synchronously, you may set variable +@code{Man-prefer-synchronous-calls} to a non-@code{nil} value. + @findex woman @cindex manual pages, on MS-DOS/MS-Windows An alternative way of reading manual pages is the @kbd{M-x woman} diff --git a/etc/NEWS b/etc/NEWS index 31fb22fc1e2..744eab41558 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -201,6 +201,13 @@ This command adds a docstring comment to the current defun. If a comment already exists, point is only moved to the comment. It is bound to 'C-c C-d' in 'go-ts-mode'. +** Man-mode + ++++ +*** New user option 'Man-prefer-synchronous-call'. +When this is non-nil, call the 'man' program synchronously rather than +asynchronously, which is the default behaviour. + * New Modes and Packages in Emacs 30.1 diff --git a/lisp/man.el b/lisp/man.el index 9f75c07c791..5e5c10aac36 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -97,6 +97,14 @@ :group 'external :group 'help) +(defcustom Man-prefer-synchronous-call nil + "Whether to call the Un*x 'man' program synchronously. +When this is non-nil, call the 'man' program synchronously +(rather than asynchronously, which is the default behaviour)." + :type 'boolean + :group 'man + :version 30.1) + (defcustom Man-filter-list nil "Manpage cleaning filter command phrases. This variable contains a list of the following form: @@ -1118,7 +1126,8 @@ Return the buffer in which the manpage will appear." "[cleaning...]") 'face 'mode-line-emphasis))) (Man-start-calling - (if (fboundp 'make-process) + (if (and (fboundp 'make-process) + (not Man-prefer-synchronous-call)) (let ((proc (start-process manual-program buffer (if (memq system-type '(cygwin windows-nt)) From 8d5d7509b0a2c248084fa349b0b188d4de4af804 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 2 Mar 2023 13:28:28 +0200 Subject: [PATCH 18/18] ; Fix last change * doc/emacs/programs.texi (Man Page): Improve wording. * lisp/man.el (Man-prefer-synchronous-call): Fix quoting and spelling. (Bug#61552) --- doc/emacs/programs.texi | 6 +++--- etc/NEWS | 2 +- lisp/man.el | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index c6c67047c43..62df88a731e 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -1389,9 +1389,9 @@ line shows how many manual pages are available. @vindex Man-prefer-synchronous-call By default, @kbd{M-x man} calls the @code{man} program -asynchronously. If you would prefer it if @kbd{M-x man} called the -@code{man} program synchronously, you may set variable -@code{Man-prefer-synchronous-calls} to a non-@code{nil} value. +asynchronously. You can force the invocation to be synchronous by +customizing @code{Man-prefer-synchronous-calls} to a non-@code{nil} +value. @findex woman @cindex manual pages, on MS-DOS/MS-Windows diff --git a/etc/NEWS b/etc/NEWS index 744eab41558..116b60d8b11 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -206,7 +206,7 @@ bound to 'C-c C-d' in 'go-ts-mode'. +++ *** New user option 'Man-prefer-synchronous-call'. When this is non-nil, call the 'man' program synchronously rather than -asynchronously, which is the default behaviour. +asynchronously (which is the default behavior). * New Modes and Packages in Emacs 30.1 diff --git a/lisp/man.el b/lisp/man.el index 5e5c10aac36..3ab9aa5b4dd 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -98,9 +98,9 @@ :group 'help) (defcustom Man-prefer-synchronous-call nil - "Whether to call the Un*x 'man' program synchronously. -When this is non-nil, call the 'man' program synchronously -(rather than asynchronously, which is the default behaviour)." + "Whether to call the Un*x \"man\" program synchronously. +When this is non-nil, call the \"man\" program synchronously +(rather than asynchronously, which is the default behavior)." :type 'boolean :group 'man :version 30.1)