commit 989cdb2c35889476702e4d2bd82d8195fa2e7ec0 (HEAD, refs/remotes/origin/master) Author: Yuan Fu Date: Thu Dec 12 21:42:44 2024 -0800 Apply string syntax only to string in jsx (bug#73978) The current code applies string syntax to too many things. This patch makes tsx-ts-mode (and friends) only apply string syntax to actual text in tsx/jsx. * lisp/progmodes/typescript-ts-mode.el: (tsx-ts--s-p-query): Only capture jsx_text. (tsx-ts--syntax-propertize-captures): handle the case when the text is one character long. diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 5389d0d64c9..edca89e5c3a 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -596,11 +596,7 @@ at least 3 (which is the default value)." (when (treesit-available-p) (treesit-query-compile 'tsx '(((regex pattern: (regex_pattern) @regexp)) - ((variable_declarator value: (jsx_element) @jsx)) - ((assignment_expression right: (jsx_element) @jsx)) - ((arguments (jsx_element) @jsx)) - ((parenthesized_expression (jsx_element) @jsx)) - ((return_statement (jsx_element) @jsx)))))) + ((jsx_text) @jsx))))) (defun typescript-ts--syntax-propertize (beg end) (let ((captures (treesit-query-capture 'typescript typescript-ts--s-p-query beg end))) @@ -621,8 +617,15 @@ at least 3 (which is the default value)." (string-to-syntax "\"/")) ('jsx (string-to-syntax "|"))))) - (put-text-property ns (1+ ns) 'syntax-table syntax) - (put-text-property (1- ne) ne 'syntax-table syntax)))) + ;; The string syntax require at least two characters (one for + ;; opening fence and one for closing fence). So if the string has + ;; only one character, we apply the whitespace syntax. The string + ;; has to be in a non-code syntax, lest the string could contain + ;; parent or brackets and messes up syntax-ppss. + (if (eq ne (1+ ns)) + (put-text-property ns ne 'syntax-table "-") + (put-text-property ns (1+ ns) 'syntax-table syntax) + (put-text-property (1- ne) ne 'syntax-table syntax))))) (if (treesit-ready-p 'tsx) (add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))) commit 9377ef5c2369202e372774c873af4d6c259cd28f Author: Yuan Fu Date: Sat Dec 7 22:13:07 2024 -0800 Declare tree-sitter functions with a new macro * lisp/progmodes/c-ts-mode.el: * lisp/progmodes/cmake-ts-mode.el: * lisp/progmodes/csharp-mode.el: * lisp/progmodes/dockerfile-ts-mode.el: * lisp/progmodes/elixir-ts-mode.el: * lisp/progmodes/go-ts-mode.el: * lisp/progmodes/heex-ts-mode.el: * lisp/progmodes/java-ts-mode.el: * lisp/progmodes/json-ts-mode.el: * lisp/progmodes/lua-ts-mode.el: * lisp/progmodes/php-ts-mode.el: * lisp/progmodes/ruby-ts-mode.el: * lisp/progmodes/rust-ts-mode.el: * lisp/progmodes/js.el: * lisp/progmodes/python.el: * lisp/progmodes/sh-script.el: * lisp/progmodes/c-ts-common.el: * lisp/progmodes/prog-mode.el: * lisp/progmodes/typescript-ts-mode.el: Use new macro. * lisp/treesit.el (treesit-declare-unavailable-functions): New macro. diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index 2689cb51133..137ff37a661 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -46,18 +46,7 @@ (require 'treesit) (eval-when-compile (require 'rx)) - -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-prev-sibling "treesit.c") -(declare-function treesit-parser-language "treesit.c") -(declare-function treesit-node-match-p "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-eq "treesit.c") -(declare-function treesit-parser-root-node "treesit.c") -(declare-function treesit-node-parser "treesit.c") +(treesit-declare-unavailable-functions) ;;; Comment indentation and filling diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 78cd6f367fb..5e3194dd82e 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -72,23 +72,7 @@ (require 'treesit) (require 'c-ts-common) (eval-when-compile (require 'rx)) - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-parser-root-node "treesit.c") -(declare-function treesit-parser-set-included-ranges "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-prev-sibling "treesit.c") -(declare-function treesit-node-first-child-for-pos "treesit.c") -(declare-function treesit-node-next-sibling "treesit.c") -(declare-function treesit-node-eq "treesit.c") -(declare-function treesit-node-match-p "treesit.c") -(declare-function treesit-query-compile "treesit.c") -(declare-function treesit-node-check "treesit.c") +(treesit-declare-unavailable-functions) ;;; Custom variables diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el index 597ef69d9b8..3ec239e89bb 100644 --- a/lisp/progmodes/cmake-ts-mode.el +++ b/lisp/progmodes/cmake-ts-mode.el @@ -29,11 +29,7 @@ (require 'treesit) (eval-when-compile (require 'rx)) - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-query-capture "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-search-subtree "treesit.c") +(treesit-declare-unavailable-functions) (defcustom cmake-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `cmake-ts-mode'." diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index b86555b1d87..0438a25242b 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -35,19 +35,12 @@ (require 'cc-langs) (require 'treesit) (require 'c-ts-common) ; For comment indenting and filling. +(treesit-declare-unavailable-functions) (eval-when-compile (require 'cc-fonts) (require 'rx)) -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-query-capture "treesit.c") -(declare-function treesit-query-compile "treesit.c") - (defgroup csharp nil "Major mode for editing C# code." :group 'prog-mode) diff --git a/lisp/progmodes/dockerfile-ts-mode.el b/lisp/progmodes/dockerfile-ts-mode.el index 42fa7482a87..a234af65a3d 100644 --- a/lisp/progmodes/dockerfile-ts-mode.el +++ b/lisp/progmodes/dockerfile-ts-mode.el @@ -29,11 +29,7 @@ (require 'treesit) (eval-when-compile (require 'rx)) - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-type "treesit.c") +(treesit-declare-unavailable-functions) (defvar dockerfile-ts-mode--syntax-table (let ((table (make-syntax-table))) diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index cacdb266298..23ad04a662d 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el @@ -45,22 +45,7 @@ (require 'treesit) (eval-when-compile (require 'rx)) - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-parser-language "treesit.c") -(declare-function treesit-parser-included-ranges "treesit.c") -(declare-function treesit-parser-list "treesit.c") -(declare-function treesit-node-p "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-query-compile "treesit.c") -(declare-function treesit-query-capture "treesit.c") -(declare-function treesit-node-eq "treesit.c") -(declare-function treesit-node-prev-sibling "treesit.c") +(treesit-declare-unavailable-functions) (defgroup elixir-ts nil "Major mode for editing Elixir code." diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index 86e74ad58a8..f3adeb9b2f3 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -29,15 +29,7 @@ (require 'treesit) (eval-when-compile (require 'rx)) - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-search-subtree "treesit.c") +(treesit-declare-unavailable-functions) (defcustom go-ts-mode-indent-offset 8 "Number of spaces for each indentation step in `go-ts-mode'." diff --git a/lisp/progmodes/heex-ts-mode.el b/lisp/progmodes/heex-ts-mode.el index 84fd513525c..7430e4f3adb 100644 --- a/lisp/progmodes/heex-ts-mode.el +++ b/lisp/progmodes/heex-ts-mode.el @@ -33,11 +33,7 @@ (require 'treesit) (eval-when-compile (require 'rx)) - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-start "treesit.c") +(treesit-declare-unavailable-functions) (defgroup heex-ts nil "Major mode for editing HEEx code." diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 177f914160c..459e57ebfb4 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -32,14 +32,7 @@ (require 'treesit) (eval-when-compile (require 'rx)) (require 'c-ts-common) ; For comment indent and filling. - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-query-capture "treesit.c") +(treesit-declare-unavailable-functions) (defcustom java-ts-mode-indent-offset 4 "Number of spaces for each indentation step in `java-ts-mode'." diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index dbf721e8d0f..b044dc44560 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -55,24 +55,12 @@ (require 'prog-mode) (require 'treesit) (require 'c-ts-common) ; For comment indent and filling. +(treesit-declare-unavailable-functions) (eval-when-compile (require 'cl-lib) (require 'rx)) -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-search-subtree "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-next-sibling "treesit.c") -(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 (defconst js--name-start-re "[[:alpha:]_$]" diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 7409c6be833..70b18ce7d95 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -29,13 +29,7 @@ (require 'treesit) (require 'rx) - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") - +(treesit-declare-unavailable-functions) (defcustom json-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `json-ts-mode'." diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el index f7669a1b015..24be7f1a09c 100644 --- a/lisp/progmodes/lua-ts-mode.el +++ b/lisp/progmodes/lua-ts-mode.el @@ -33,23 +33,11 @@ (require 'comint) (require 'treesit) +(treesit-declare-unavailable-functions) (eval-when-compile (require 'rx)) -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-child-count "treesit.c") -(declare-function treesit-node-eq "treesit.c") -(declare-function treesit-node-first-child-for-pos "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-prev-sibling "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-search-subtree "treesit.c") - (defgroup lua-ts nil "Major mode for editing Lua files." :prefix "lua-ts-" diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index 10f290d24ea..5d360a6818b 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -58,30 +58,13 @@ (require 'css-mode) ;; for embed css into html (require 'js) ;; for embed javascript into html (require 'comint) +(treesit-declare-unavailable-functions) (eval-when-compile (require 'cl-lib) (require 'rx) (require 'subr-x)) -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-string "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-parser-add-notifier "treesit.c") -(declare-function treesit-parser-buffer "treesit.c") -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-parser-included-ranges "treesit.c") -(declare-function treesit-parser-list "treesit.c") -(declare-function treesit-parser-language "treesit.c") -(declare-function treesit-query-compile "treesit.c") -(declare-function treesit-search-forward "treesit.c") -(declare-function treesit-node-prev-sibling "treesit.c") -(declare-function treesit-node-first-child-for-pos "treesit.c") - ;;; Install treesitter language parsers (defvar php-ts-mode--language-source-alist '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.23.11" "php/src")) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index d4e0514a6c3..d27b29f1626 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -33,11 +33,7 @@ (require 'subr-x) (require 'treesit)) -(declare-function treesit-available-p "treesit.c") -(declare-function treesit-parser-list "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-at "treesit.c") -(declare-function treesit-node-match-p "treesit.c") +(treesit-declare-unavailable-functions) (defgroup prog-mode nil "Generic programming mode, from which others derive." diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index cfa3cc59568..4a1cfc6c072 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -259,20 +259,12 @@ (require 'compat) (require 'project nil 'noerror) (require 'seq) +(treesit-declare-unavailable-functions) ;; Avoid compiler warnings (defvar compilation-error-regexp-alist) (defvar outline-heading-end-regexp) -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-prev-sibling "treesit.c") - (autoload 'comint-mode "comint") (autoload 'help-function-arglist "help-fns") diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 2b36c68bb6c..7d108ed9841 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -112,23 +112,7 @@ (require 'treesit) (require 'ruby-mode) - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-search-subtree "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-next-sibling "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-string "treesit.c") -(declare-function treesit-query-compile "treesit.c") -(declare-function treesit-query-capture "treesit.c") -(declare-function treesit-parser-add-notifier "treesit.c") -(declare-function treesit-parser-buffer "treesit.c") -(declare-function treesit-parser-list "treesit.c") +(treesit-declare-unavailable-functions) (defgroup ruby-ts nil "Major mode for editing Ruby code." diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el index 7a421eb506b..ee749e963cd 100644 --- a/lisp/progmodes/rust-ts-mode.el +++ b/lisp/progmodes/rust-ts-mode.el @@ -30,16 +30,7 @@ (require 'treesit) (eval-when-compile (require 'rx)) (require 'c-ts-common) ; For comment indent and filling. - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-query-compile "treesit.c") +(treesit-declare-unavailable-functions) (defcustom rust-ts-mode-indent-offset 4 "Number of spaces for each indentation step in `rust-ts-mode'." diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 15ba6e6f2a0..eb024ddc475 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -149,8 +149,7 @@ (require 'subr-x)) (require 'executable) (require 'treesit) - -(declare-function treesit-parser-create "treesit.c") +(treesit-declare-unavailable-functions) (autoload 'comint-completion-at-point "comint") (autoload 'comint-filename-completion "comint") diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 3dfb623c667..5389d0d64c9 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -31,13 +31,7 @@ (require 'js) (eval-when-compile (require 'rx)) (require 'c-ts-common) ; For comment indent and filling. - -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-query-capture "treesit.c") -(declare-function treesit-query-compile "treesit.c") +(treesit-declare-unavailable-functions) (defcustom typescript-ts-mode-indent-offset 2 "Number of spaces for each indentation step in `typescript-ts-mode'." diff --git a/lisp/treesit.el b/lisp/treesit.el index db8f7a7595d..18200acf53f 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -39,61 +39,69 @@ ;;; Function declarations -(declare-function treesit-language-available-p "treesit.c") -(declare-function treesit-language-version "treesit.c") - -(declare-function treesit-parser-p "treesit.c") -(declare-function treesit-node-p "treesit.c") -(declare-function treesit-compiled-query-p "treesit.c") -(declare-function treesit-query-p "treesit.c") -(declare-function treesit-query-language "treesit.c") - -(declare-function treesit-node-parser "treesit.c") - -(declare-function treesit-parser-create "treesit.c") -(declare-function treesit-parser-delete "treesit.c") -(declare-function treesit-parser-list "treesit.c") -(declare-function treesit-parser-buffer "treesit.c") -(declare-function treesit-parser-language "treesit.c") -(declare-function treesit-parser-tag "treesit.c") - -(declare-function treesit-parser-root-node "treesit.c") - -(declare-function treesit-parser-set-included-ranges "treesit.c") -(declare-function treesit-parser-included-ranges "treesit.c") -(declare-function treesit-parser-changed-ranges "treesit.c") -(declare-function treesit-parser-add-notifier "treesit.c") - -(declare-function treesit-node-type "treesit.c") -(declare-function treesit-node-start "treesit.c") -(declare-function treesit-node-end "treesit.c") -(declare-function treesit-node-string "treesit.c") -(declare-function treesit-node-parent "treesit.c") -(declare-function treesit-node-child "treesit.c") -(declare-function treesit-node-check "treesit.c") -(declare-function treesit-node-field-name-for-child "treesit.c") -(declare-function treesit-node-child-count "treesit.c") -(declare-function treesit-node-child-by-field-name "treesit.c") -(declare-function treesit-node-next-sibling "treesit.c") -(declare-function treesit-node-prev-sibling "treesit.c") -(declare-function treesit-node-first-child-for-pos "treesit.c") -(declare-function treesit-node-descendant-for-range "treesit.c") -(declare-function treesit-node-eq "treesit.c") - -(declare-function treesit-pattern-expand "treesit.c") -(declare-function treesit-query-expand "treesit.c") -(declare-function treesit-query-compile "treesit.c") -(declare-function treesit-query-capture "treesit.c") - -(declare-function treesit-search-subtree "treesit.c") -(declare-function treesit-search-forward "treesit.c") -(declare-function treesit-induce-sparse-tree "treesit.c") -(declare-function treesit-subtree-stat "treesit.c") -(declare-function treesit-node-match-p "treesit.c") - -(declare-function treesit-available-p "treesit.c") - -(defvar treesit-thing-settings) +(defmacro treesit-declare-unavailable-functions () + "Declare C functions and variables defined in treesit.c. + +This macro is only needed when a file needs to be able to byte-compile +in a Emacs not built with tree-sitter library." + '(progn + (declare-function treesit-language-available-p "treesit.c") + (declare-function treesit-language-version "treesit.c") + + (declare-function treesit-parser-p "treesit.c") + (declare-function treesit-node-p "treesit.c") + (declare-function treesit-compiled-query-p "treesit.c") + (declare-function treesit-query-p "treesit.c") + (declare-function treesit-query-language "treesit.c") + + (declare-function treesit-node-parser "treesit.c") + + (declare-function treesit-parser-create "treesit.c") + (declare-function treesit-parser-delete "treesit.c") + (declare-function treesit-parser-list "treesit.c") + (declare-function treesit-parser-buffer "treesit.c") + (declare-function treesit-parser-language "treesit.c") + (declare-function treesit-parser-tag "treesit.c") + + (declare-function treesit-parser-root-node "treesit.c") + + (declare-function treesit-parser-set-included-ranges "treesit.c") + (declare-function treesit-parser-included-ranges "treesit.c") + (declare-function treesit-parser-changed-ranges "treesit.c") + (declare-function treesit-parser-add-notifier "treesit.c") + + (declare-function treesit-node-type "treesit.c") + (declare-function treesit-node-start "treesit.c") + (declare-function treesit-node-end "treesit.c") + (declare-function treesit-node-string "treesit.c") + (declare-function treesit-node-parent "treesit.c") + (declare-function treesit-node-child "treesit.c") + (declare-function treesit-node-check "treesit.c") + (declare-function treesit-node-field-name-for-child "treesit.c") + (declare-function treesit-node-child-count "treesit.c") + (declare-function treesit-node-child-by-field-name "treesit.c") + (declare-function treesit-node-next-sibling "treesit.c") + (declare-function treesit-node-prev-sibling "treesit.c") + (declare-function treesit-node-first-child-for-pos "treesit.c") + (declare-function treesit-node-descendant-for-range "treesit.c") + (declare-function treesit-node-eq "treesit.c") + + (declare-function treesit-pattern-expand "treesit.c") + (declare-function treesit-query-expand "treesit.c") + (declare-function treesit-query-compile "treesit.c") + (declare-function treesit-query-capture "treesit.c") + + (declare-function treesit-search-subtree "treesit.c") + (declare-function treesit-search-forward "treesit.c") + (declare-function treesit-induce-sparse-tree "treesit.c") + (declare-function treesit-subtree-stat "treesit.c") + (declare-function treesit-node-match-p "treesit.c") + + (declare-function treesit-available-p "treesit.c") + + (defvar treesit-thing-settings))) + +(treesit-declare-unavailable-functions) ;;; Custom options commit 4bdadbdc215aacdc474b33426bf8eb1a1bd54e1f Author: Stefan Kangas Date: Fri Dec 13 04:48:33 2024 +0100 Prefer defvar-keymap in perl-mode.el * lisp/progmodes/perl-mode.el (perl-mode-map): Convert to defvar-keymap. diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 3c32fac3f42..a503aa4dee6 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -100,15 +100,13 @@ "Abbrev table in use in `perl-mode' buffers.") (define-abbrev-table 'perl-mode-abbrev-table ()) -(defvar perl-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "\e\C-a" 'perl-beginning-of-function) - (define-key map "\e\C-e" 'perl-end-of-function) - (define-key map "\e\C-h" 'perl-mark-function) - (define-key map "\e\C-q" 'perl-indent-exp) - (define-key map "\177" 'backward-delete-char-untabify) - map) - "Keymap used in Perl mode.") +(defvar-keymap perl-mode-map + :doc "Keymap used in Perl mode." + "C-M-a" #'perl-beginning-of-function + "C-M-e" #'perl-end-of-function + "C-M-h" #'perl-mark-function + "C-M-q" #'perl-indent-exp + "DEL" #'backward-delete-char-untabify) (defvar perl-mode-syntax-table (let ((st (make-syntax-table (standard-syntax-table)))) commit a9fcf55d5bb25bd2535d2595652ef15bd3816cea Author: Stefan Kangas Date: Fri Dec 13 04:44:30 2024 +0100 Prefer defvar-keymap in f90.el * lisp/progmodes/f90.el (f90-mode-map): Convert to defvar-keymap. (f90-menu): Move definition to top level. diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index ec9d1995547..d6e7932d2f1 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el @@ -1,6 +1,6 @@ ;;; f90.el --- Fortran-90 mode (free format) -*- lexical-binding: t -*- -;; Copyright (C) 1995-1997, 2000-2024 Free Software Foundation, Inc. +;; Copyright (C) 1995-2024 Free Software Foundation, Inc. ;; Author: Torbjörn Einarsson ;; Maintainer: emacs-devel@gnu.org @@ -723,109 +723,104 @@ Can be overridden by the value of `font-lock-maximum-decoration'.") table) "Syntax table used in F90 mode.") -(defvar f90-mode-map - (let ((map (make-sparse-keymap))) - (define-key map "`" 'f90-abbrev-start) - (define-key map "\C-c;" 'f90-comment-region) - (define-key map "\C-\M-a" 'f90-beginning-of-subprogram) - (define-key map "\C-\M-e" 'f90-end-of-subprogram) - (define-key map "\C-\M-h" 'f90-mark-subprogram) - (define-key map "\C-\M-n" 'f90-end-of-block) - (define-key map "\C-\M-p" 'f90-beginning-of-block) - (define-key map "\C-\M-q" 'f90-indent-subprogram) - (define-key map "\C-j" 'f90-indent-new-line) ; LFD equals C-j -;;; (define-key map "\r" 'newline) - (define-key map "\C-c\r" 'f90-break-line) -;;; (define-key map [M-return] 'f90-break-line) - (define-key map "\C-c\C-a" 'f90-previous-block) - (define-key map "\C-c\C-e" 'f90-next-block) - (define-key map "\C-c\C-d" 'f90-join-lines) - (define-key map "\C-c\C-f" 'f90-fill-region) - (define-key map "\C-c\C-p" 'f90-previous-statement) - (define-key map "\C-c\C-n" 'f90-next-statement) - (define-key map "\C-c]" 'f90-insert-end) - (define-key map "\C-c\C-w" 'f90-insert-end) - ;; Standard tab binding will call this, and also handle regions. -;;; (define-key map "\t" 'f90-indent-line) - (define-key map "," 'f90-electric-insert) - (define-key map "+" 'f90-electric-insert) - (define-key map "-" 'f90-electric-insert) - (define-key map "*" 'f90-electric-insert) - (define-key map "/" 'f90-electric-insert) - - (easy-menu-define f90-menu map "Menu for F90 mode." - `("F90" - ("Customization" - ,(custom-menu-create 'f90) - ;; FIXME useless? - ["Set" Custom-set :active t - :help "Set current value of all edited settings in the buffer"] - ["Save" Custom-save :active t - :help "Set and save all edited settings"] - ["Reset to Current" Custom-reset-current :active t - :help "Reset all edited settings to current"] - ["Reset to Saved" Custom-reset-saved :active t - :help "Reset all edited or set settings to saved"] - ["Reset to Standard Settings" Custom-reset-standard :active t - :help "Erase all customizations in buffer"] - ) - "--" - ["Indent Subprogram" f90-indent-subprogram t] - ["Mark Subprogram" f90-mark-subprogram :active t :help - "Mark the end of the current subprogram, move point to the start"] - ["Beginning of Subprogram" f90-beginning-of-subprogram :active t - :help "Move point to the start of the current subprogram"] - ["End of Subprogram" f90-end-of-subprogram :active t - :help "Move point to the end of the current subprogram"] - "--" - ["(Un)Comment Region" f90-comment-region :active mark-active - :help "Comment or uncomment the region"] - ["Indent Region" f90-indent-region :active mark-active] - ["Fill Region" f90-fill-region :active mark-active - :help "Fill long lines in the region"] - ["Fill Statement/Comment" fill-paragraph :active t] - "--" - ["Break Line at Point" f90-break-line :active t - :help "Break the current line at point"] - ["Join with Previous Line" f90-join-lines :active t - :help "Join the current line to the previous one"] - ["Insert Block End" f90-insert-end :active t - :help "Insert an end statement for the current code block"] - "--" - ("Highlighting" - :help "Fontify this buffer to varying degrees" - ["Toggle font-lock-mode" font-lock-mode :selected font-lock-mode - :style toggle :help "Fontify text in this buffer"] - "--" - ["Light highlighting (level 1)" f90-font-lock-1 t] - ["Moderate highlighting (level 2)" f90-font-lock-2 t] - ["Heavy highlighting (level 3)" f90-font-lock-3 t] - ["Maximum highlighting (level 4)" f90-font-lock-4 t] - ) - ("Change Keyword Case" - :help "Change the case of keywords in the buffer or region" - ["Upcase Keywords (buffer)" f90-upcase-keywords t] - ["Capitalize Keywords (buffer)" f90-capitalize-keywords t] - ["Downcase Keywords (buffer)" f90-downcase-keywords t] - "--" - ["Upcase Keywords (region)" f90-upcase-region-keywords - mark-active] - ["Capitalize Keywords (region)" f90-capitalize-region-keywords - mark-active] - ["Downcase Keywords (region)" f90-downcase-region-keywords - mark-active] - ) - "--" - ["Toggle Auto Fill" auto-fill-mode :selected auto-fill-function - :style toggle - :help "Automatically fill text while typing in this buffer"] - ["Toggle Abbrev Mode" abbrev-mode :selected abbrev-mode - :style toggle :help "Expand abbreviations while typing in this buffer"] - ["Add Imenu Menu" f90-add-imenu-menu - :active (not (lookup-key (current-local-map) [menu-bar index])) - :help "Add an index menu to the menu-bar"])) - map) - "Keymap used in F90 mode.") +(defvar-keymap f90-mode-map + :doc "Keymap used in F90 mode." + "`" #'f90-abbrev-start + "C-c ;" #'f90-comment-region + "C-M-a" #'f90-beginning-of-subprogram + "C-M-e" #'f90-end-of-subprogram + "C-M-h" #'f90-mark-subprogram + "C-M-n" #'f90-end-of-block + "C-M-p" #'f90-beginning-of-block + "C-M-q" #'f90-indent-subprogram + "C-j" #'f90-indent-new-line ; LFD equals C-j + "C-c RET" #'f90-break-line + "C-c C-a" #'f90-previous-block + "C-c C-e" #'f90-next-block + "C-c C-d" #'f90-join-lines + "C-c C-f" #'f90-fill-region + "C-c C-p" #'f90-previous-statement + "C-c C-n" #'f90-next-statement + "C-c ]" #'f90-insert-end + "C-c C-w" #'f90-insert-end + "," #'f90-electric-insert + "+" #'f90-electric-insert + "-" #'f90-electric-insert + "*" #'f90-electric-insert + "/" #'f90-electric-insert) + +(easy-menu-define f90-menu f90-mode-map + "Menu for F90 mode." + `("F90" + ("Customization" + ,(custom-menu-create 'f90) + ;; FIXME useless? + ["Set" Custom-set :active t + :help "Set current value of all edited settings in the buffer"] + ["Save" Custom-save :active t + :help "Set and save all edited settings"] + ["Reset to Current" Custom-reset-current :active t + :help "Reset all edited settings to current"] + ["Reset to Saved" Custom-reset-saved :active t + :help "Reset all edited or set settings to saved"] + ["Reset to Standard Settings" Custom-reset-standard :active t + :help "Erase all customizations in buffer"] + ) + "--" + ["Indent Subprogram" f90-indent-subprogram t] + ["Mark Subprogram" f90-mark-subprogram :active t :help + "Mark the end of the current subprogram, move point to the start"] + ["Beginning of Subprogram" f90-beginning-of-subprogram :active t + :help "Move point to the start of the current subprogram"] + ["End of Subprogram" f90-end-of-subprogram :active t + :help "Move point to the end of the current subprogram"] + "--" + ["(Un)Comment Region" f90-comment-region :active mark-active + :help "Comment or uncomment the region"] + ["Indent Region" f90-indent-region :active mark-active] + ["Fill Region" f90-fill-region :active mark-active + :help "Fill long lines in the region"] + ["Fill Statement/Comment" fill-paragraph :active t] + "--" + ["Break Line at Point" f90-break-line :active t + :help "Break the current line at point"] + ["Join with Previous Line" f90-join-lines :active t + :help "Join the current line to the previous one"] + ["Insert Block End" f90-insert-end :active t + :help "Insert an end statement for the current code block"] + "--" + ("Highlighting" + :help "Fontify this buffer to varying degrees" + ["Toggle font-lock-mode" font-lock-mode :selected font-lock-mode + :style toggle :help "Fontify text in this buffer"] + "--" + ["Light highlighting (level 1)" f90-font-lock-1 t] + ["Moderate highlighting (level 2)" f90-font-lock-2 t] + ["Heavy highlighting (level 3)" f90-font-lock-3 t] + ["Maximum highlighting (level 4)" f90-font-lock-4 t] + ) + ("Change Keyword Case" + :help "Change the case of keywords in the buffer or region" + ["Upcase Keywords (buffer)" f90-upcase-keywords t] + ["Capitalize Keywords (buffer)" f90-capitalize-keywords t] + ["Downcase Keywords (buffer)" f90-downcase-keywords t] + "--" + ["Upcase Keywords (region)" f90-upcase-region-keywords + mark-active] + ["Capitalize Keywords (region)" f90-capitalize-region-keywords + mark-active] + ["Downcase Keywords (region)" f90-downcase-region-keywords + mark-active] + ) + "--" + ["Toggle Auto Fill" auto-fill-mode :selected auto-fill-function + :style toggle + :help "Automatically fill text while typing in this buffer"] + ["Toggle Abbrev Mode" abbrev-mode :selected abbrev-mode + :style toggle :help "Expand abbreviations while typing in this buffer"] + ["Add Imenu Menu" f90-add-imenu-menu + :active (not (lookup-key (current-local-map) [menu-bar index])) + :help "Add an index menu to the menu-bar"])) (defun f90-font-lock-n (n) commit 65aa5608f2c02bb90742d4d176c61182915f7755 Author: Stefan Kangas Date: Fri Dec 13 04:40:02 2024 +0100 Prefer defvar-keymap in dired.el * lisp/dired.el (dired-mouse-drag-files-map) (dired-click-to-select-map): Convert to defvar-keymap. diff --git a/lisp/dired.el b/lisp/dired.el index 9895229694a..028b862d159 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1962,13 +1962,12 @@ other marked file as well. Otherwise, unmark all files." ;; a remote file. (user-error (cadr error))))))))))) -(defvar dired-mouse-drag-files-map (let ((keymap (make-sparse-keymap))) - (define-key keymap [down-mouse-1] #'dired-mouse-drag) - (define-key keymap [C-down-mouse-1] #'dired-mouse-drag) - (define-key keymap [S-down-mouse-1] #'dired-mouse-drag) - (define-key keymap [M-down-mouse-1] #'dired-mouse-drag) - keymap) - "Keymap applied to file names when `dired-mouse-drag-files' is enabled.") +(defvar-keymap dired-mouse-drag-files-map + :doc "Keymap applied to file names when `dired-mouse-drag-files' is enabled." + "" #'dired-mouse-drag + "C-" #'dired-mouse-drag + "S-" #'dired-mouse-drag + "M-" #'dired-mouse-drag) (defvar dired-click-to-select-mode) (defvar dired-click-to-select-map) @@ -5290,8 +5289,8 @@ Interactively with prefix argument, read FILE-NAME." ;;; Click-To-Select mode -(defvar dired-click-to-select-map (make-sparse-keymap) - "Keymap placed on files under `dired-click-to-select' mode.") +(defvar-keymap dired-click-to-select-map + :doc "Keymap placed on files under `dired-click-to-select' mode.") (define-key dired-click-to-select-map [mouse-2] #'dired-mark-for-click) commit 020128e9dc31fb3b06c39614b7eb20ddb5b3725a Author: Stefan Kangas Date: Fri Dec 13 01:13:52 2024 +0100 Don't use obsolete mode delhpi-mode * lisp/files.el (auto-mode-alist): Prefer opascal-mode to obsolete delphi-mode. diff --git a/lisp/files.el b/lisp/files.el index a65bc4a4ea2..9f13804540b 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2978,7 +2978,7 @@ since only a single case-insensitive search through the alist is made." ("\\.for\\'" . fortran-mode) ("\\.p\\'" . pascal-mode) ("\\.pas\\'" . pascal-mode) - ("\\.\\(dpr\\|DPR\\)\\'" . delphi-mode) + ("\\.\\(dpr\\|DPR\\)\\'" . opascal-mode) ("\\.\\([pP]\\([Llm]\\|erl\\|od\\)\\|al\\)\\'" . perl-mode) ("Imakefile\\'" . makefile-imake-mode) ("Makeppfile\\(?:\\.mk\\)?\\'" . makefile-makepp-mode) ; Put this before .mk commit d1bde7b5cb727d6b0559d99669719d5eb832c186 Author: Stefan Kangas Date: Fri Dec 13 00:03:13 2024 +0100 Don't use obsolete filter-buffer-substring-functions in Org This patch was also installed in Org mode, here: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=b9637ef142 * lisp/org/org-agenda.el (org-agenda-mode): * lisp/org/org-indent.el (org-indent-mode): Don't use obsolete filter-buffer-substring-functions. diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index 011884d5d5b..ba13de8f679 100644 --- a/lisp/org/org-agenda.el +++ b/lisp/org/org-agenda.el @@ -2375,14 +2375,8 @@ The following commands are available: (add-hook 'post-command-hook #'org-agenda-update-agenda-type nil 'local) (add-hook 'pre-command-hook #'org-unhighlight nil 'local) ;; Make sure properties are removed when copying text - (if (boundp 'filter-buffer-substring-functions) - (add-hook 'filter-buffer-substring-functions - (lambda (fun start end delete) - (substring-no-properties (funcall fun start end delete))) - nil t) - ;; Emacs >= 24.4. - (add-function :filter-return (local 'filter-buffer-substring-function) - #'substring-no-properties)) + (add-function :filter-return (local 'filter-buffer-substring-function) + #'substring-no-properties) (unless org-agenda-keep-modes (setq org-agenda-follow-mode org-agenda-start-with-follow-mode org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode diff --git a/lisp/org/org-indent.el b/lisp/org/org-indent.el index cabed6acf72..a0a0740eef9 100644 --- a/lisp/org/org-indent.el +++ b/lisp/org/org-indent.el @@ -193,15 +193,8 @@ during idle time." (when org-indent-mode-turns-on-hiding-stars (setq-local org-hide-leading-stars t)) (org-indent--compute-prefixes) - (if (boundp 'filter-buffer-substring-functions) - (add-hook 'filter-buffer-substring-functions - (lambda (fun start end delete) - (org-indent-remove-properties-from-string - (funcall fun start end delete))) - nil t) - ;; Emacs >= 24.4. - (add-function :filter-return (local 'filter-buffer-substring-function) - #'org-indent-remove-properties-from-string)) + (add-function :filter-return (local 'filter-buffer-substring-function) + #'org-indent-remove-properties-from-string) (add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local) (add-hook 'before-change-functions 'org-indent-notify-modified-headline nil 'local) @@ -224,13 +217,8 @@ during idle time." (set-marker org-indent--initial-marker nil)) (when (local-variable-p 'org-hide-leading-stars) (kill-local-variable 'org-hide-leading-stars)) - (if (boundp 'filter-buffer-substring-functions) - (remove-hook 'filter-buffer-substring-functions - (lambda (fun start end delete) - (org-indent-remove-properties-from-string - (funcall fun start end delete)))) - (remove-function (local 'filter-buffer-substring-function) - #'org-indent-remove-properties-from-string)) + (remove-function (local 'filter-buffer-substring-function) + #'org-indent-remove-properties-from-string) (remove-hook 'after-change-functions 'org-indent-refresh-maybe 'local) (remove-hook 'before-change-functions 'org-indent-notify-modified-headline 'local) commit 9ccd459e8452cc9e6e81e53f26bbeef20d2d5bb7 Author: Jared Finder Date: Mon Dec 9 22:16:40 2024 -0800 Enable xterm-mouse-mode by default in xterm * lisp/xt-mouse.el (xterm-mouse-mode): Change default value of xterm-mouse-mode to t. * lisp/term/xterm.el (xterm--init): Enable xterm-mouse-mode if the default value is still set. * etc/NEWS: Document new behavior. diff --git a/etc/NEWS b/etc/NEWS index a9978329eb8..d96e49402ba 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -41,6 +41,12 @@ why the mark trace buffer is enabled by default. * Startup Changes in Emacs 31.1 +** When run inside xterm, 'xterm-mouse-mode' is turned on by default. +This means that the mouse will work by default inside xterm terminals. +If your terminal does not behave properly with xterm mouse tracking +enabled, you can disable mouse tracking by putting '(xterm-mouse-mode +-1)' in your init file. + * Changes in Emacs 31.1 diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index 82f9a60b53b..c4f33cd0faa 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -907,6 +907,8 @@ We run the first FUNCTION whose STRING matches the input events." (when xterm-set-window-title (xterm--init-frame-title)) + (when xterm-mouse-mode + (xterm-mouse-mode 1)) ;; Unconditionally enable bracketed paste mode: terminals that don't ;; support it just ignore the sequence. (xterm--init-bracketed-paste-mode) diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index 8cbb44ece14..c77d763702c 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el @@ -358,6 +358,8 @@ single clicks are supported. When turned on, the normal xterm mouse functionality for such clicks is still available by holding down the SHIFT key while pressing the mouse button." :global t :group 'mouse + :init-value t + :version "31.1" (funcall (if xterm-mouse-mode 'add-hook 'remove-hook) 'terminal-init-xterm-hook 'turn-on-xterm-mouse-tracking-on-terminal) commit a4548739b8ed3ba20223d1043390f71afcdd8a2f Author: Diancheng Wang Date: Thu Dec 5 15:34:44 2024 +0800 Turn off current source line indicator when gdb buffer is killed * lisp/progmodes/gud.el (gud-hide-current-line-indicator): Turn off current-line indicator. (Bug#74642) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index a4e611277e4..70daa087c2b 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -2962,6 +2962,8 @@ It is nil if not yet present.") (defun gud-sentinel (proc msg) (cond ((null (buffer-name (process-buffer proc))) ;; buffer killed + ;; Stop displaying an arrow and highlight overlay in a source file. + (gud-hide-current-line-indicator t) (set-process-buffer proc nil) (if (and (boundp 'speedbar-initial-expansion-list-name) (string-equal speedbar-initial-expansion-list-name "GUD")) commit a3610381ff65490da33cd1870dd3dfd491bff06f Author: Daniel Mendler Date: Sat Dec 7 22:56:15 2024 +0100 eww: Use browse-url-with-browser-kind in eww-browse-with-external-browser Guarantee that an external browser is used by EWW if `browse-url-secondary-browser-function' is set to `eww-browse-url'. * lisp/net/eww.el (eww-browse-with-external-browser): Use `browse-url-secondary-browser-function' only if it is an external browser, otherwise fall back to `browse-url-with-browser-kind'. (eww-follow-link): Use `eww-browse-with-external-browser' if the EXTERNAL prefix argument is non-nil. Improve docstring. * lisp/net/browse-url.el (browse-url-secondary-browser-function): Update docstring. (Bug#74730) diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index a4de177f972..de2fa9c2bfb 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -198,10 +198,16 @@ Also see `browse-url-secondary-browser-function' and (defcustom browse-url-secondary-browser-function 'browse-url-default-browser "Function used to launch an alternative browser. -This is usually an external browser (that is, not eww or w3m), -used as the secondary browser choice, typically when a prefix -argument is given to a URL-opening command in those modes that -support this (for instance, eww/shr). + +This browser is used as the secondary browser choice, typically +when a prefix argument is given to a URL-opening command in those +modes that support this (for instance `browse-url-at-point', +`goto-addr-at-point', eww or shr). + +This assumption is that `browse-url-secondary-browser-function' +and `browse-url-browser-function' are set to distinct browsers. +Either one of the two functions should call an external browser +and the other one should not do the same. Also see `browse-url-browser-function'." :version "27.1" diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 4d4d4d6beac..4609755a902 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -2142,11 +2142,15 @@ Interactively, EVENT is the value of `last-nonmenu-event'." (defun eww-browse-with-external-browser (&optional url) "Browse the current URL with an external browser. -The browser to used is specified by the -`browse-url-secondary-browser-function' variable." +Use `browse-url-secondary-browser-function' if it is an external +browser, otherwise use `browse-url-with-browser-kind' to open an +external browser." (interactive nil eww-mode) - (funcall browse-url-secondary-browser-function - (or url (plist-get eww-data :url)))) + (setq url (or url (plist-get eww-data :url))) + (if (eq 'external (browse-url--browser-kind + browse-url-secondary-browser-function url)) + (funcall browse-url-secondary-browser-function url) + (browse-url-with-browser-kind 'external url))) (defun eww-remove-tracking (url) "Remove the commong utm_ tracking cookies from URLs." @@ -2160,11 +2164,12 @@ The browser to used is specified by the url)) (defun eww-follow-link (&optional external mouse-event) - "Browse the URL under point. -If EXTERNAL is single prefix, browse the URL using -`browse-url-secondary-browser-function'. + "Browse the URL at point, optionally the position of MOUSE-EVENT. -If EXTERNAL is double prefix, browse in new buffer." +EXTERNAL is the prefix argument. If called interactively with +\\[universal-argument] pressed once, browse the URL using +`eww-browse-with-external-browser'. If called interactively, with +\\[universal-argument] pressed twice, browse in new buffer." (interactive (list current-prefix-arg last-nonmenu-event) eww-mode) @@ -2180,7 +2185,7 @@ If EXTERNAL is double prefix, browse in new buffer." ;; and `browse-url-mailto-function'. (browse-url url)) ((and (consp external) (<= (car external) 4)) - (funcall browse-url-secondary-browser-function url) + (eww-browse-with-external-browser url) (shr--blink-link)) ;; This is a #target url in the same page as the current one. ((and (setq target (url-target (url-generic-parse-url url))) commit eb9ba4830e4c7853150eaed93f89225c00d6e52a Author: Visuwesh Date: Thu Dec 5 11:40:02 2024 +0530 Revert Dired buffer when clicking on basename of directory * lisp/dired.el (dired--make-directory-clickable): Make clicking on basename of the directory revert the Dired buffer. * etc/NEWS: Announce the change. (Bug#74700) diff --git a/etc/NEWS b/etc/NEWS index e6227009725..a9978329eb8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -685,6 +685,11 @@ Without 'dired-hide-details-hide-absolute-location': /absolute/path/to/my/important/project: (100 GiB available) +--- +*** Clicking on base name of directory reverts buffer. +When 'dired-make-directory-clickable' is non-nil, clicking on the base +name of the directory now reverts the Dired buffer. + ** Grep +++ diff --git a/lisp/dired.el b/lisp/dired.el index f79a2220bea..9895229694a 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -2082,7 +2082,16 @@ mouse-2: visit this file in other window" "" click "" 'mouse-face "RET" click)))) - (setq segment-start (point))))))) + (setq segment-start (point))) + (when (search-forward ":" bound t) + (add-text-properties + segment-start (1- (point)) + `(mouse-face highlight + help-echo "mouse-1: re-read this buffer's directory" + keymap ,(define-keymap + "" #'revert-buffer + "" 'follow-link + "RET" #'revert-buffer)))))))) (defun dired--get-ellipsis-length () "Return length of ellipsis." commit d181afa5d96e66cbedf2d1a5e7ff3235222a92f1 Author: Stefan Kangas Date: Wed Dec 11 22:34:19 2024 +0100 Add nntps and snews to browse-url heuristic * lisp/net/browse-url.el (browse-url-button-regexp): Support "nntps" and "snews" schemes. diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 6a00bbbef93..a4de177f972 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -237,7 +237,7 @@ be used instead." (defcustom browse-url-button-regexp (concat "\\b\\(\\(www\\.\\|\\(s?https?\\|ftps?\\|file\\|gophers?\\|gemini\\|" - "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)" + "nntps?\\|s?news\\|telnet\\|wais\\|mailto\\|info\\):\\)" "\\(//[-a-z0-9_.]+:[0-9]*\\)?" (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]") (punct "!?:;.,")) @@ -252,7 +252,7 @@ be used instead." "\\)")) "\\)") "Regular expression that matches URLs." - :version "27.1" + :version "31.1" :type 'regexp) (defcustom browse-url-browser-display nil commit ab5040896e6d436ec4c13371721e5218348a6555 Author: Stefan Kangas Date: Wed Dec 11 22:32:54 2024 +0100 Shorten browse-url-default-scheme docstring * lisp/net/browse-url.el (browse-url-default-scheme): Shorten docstring by removing self-evident information. Reflow. diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index ef919d4e4ed..6a00bbbef93 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -674,13 +674,9 @@ regarding its parameter treatment." (defcustom browse-url-default-scheme "http" "URL scheme that `browse-url' (and related commands) will use by default. -For example, when point is on an URL fragment like -\"www.example.org\", `browse-url' will assume that this is an -\"http\" URL by default (i.e. \"http://www.example.org\"). - -Note that if you set this to \"https\", websites that do not yet -support HTTPS may not load correctly in your web browser. Such -websites are increasingly rare, but they do still exist." +For example, when point is on an URL fragment like \"www.example.org\", +`browse-url' will assume that this is an \"http\" URL by default (for +example, \"http://www.example.org\")." :type '(choice (const :tag "HTTP" "http") (const :tag "HTTPS" "https") (string :tag "Something else" "https"))