Stefan Kangas [Mon, 6 Jan 2025 11:29:21 +0000 (12:29 +0100)]
Fix finding C headers with clang
This fixes following "#include" references in 'M-x man' buffers, and
using ffap, both on macOS machines, and on systems where for some reason
clang is available but gcc is not.
* lisp/subr.el (internal--c-header-file-path): Fix finding C
headers with clang.
(internal--gcc-is-clang-p): New function factored out from...
* lisp/emacs-lisp/ert-x.el (ert-gcc-is-clang-p): ...here.
* lisp/man.el (Man-header-file-path): Bump :version tag.
* test/lisp/subr-tests.el
(subr-tests-internal--c-header-file-path/clang-mocked): New test.
Stefan Kangas [Mon, 6 Jan 2025 09:08:01 +0000 (10:08 +0100)]
New function internal--c-header-file-path
It is not clear to me where this function properly belongs, so let's put
it in subr.el for now. This avoids code duplication without introducing
a dependency between man and ffap. It can always be moved later.
* lisp/subr.el (internal--c-header-file-path): New function.
* lisp/man.el (Man-header-file-path):
* lisp/ffap.el (ffap-c-path): Use above new function.
* test/lisp/subr-tests.el (ert-x): Require.
(subr-tests-internal--c-header-file-path)
(subr-tests-internal--c-header-file-path/gcc-mocked): New tests.
Stephen Gildea [Mon, 6 Jan 2025 19:00:07 +0000 (11:00 -0800)]
time-stamp: lower- and title-case weekday and month names
* lisp/time-stamp.el (time-stamp-string-preprocess): new formats for
lowercase weekday name, lowercase month name, and system name
* test/lisp/time-stamp.el: new tests
(formatz-generate-tests): Better doc strings for generated test fns.
Juri Linkov [Mon, 6 Jan 2025 18:02:18 +0000 (20:02 +0200)]
* lisp/treesit.el: Use forward-list-default-function for C-M-n
(treesit--forward-list-with-default): New internal function
with body from 'treesit-forward-sexp-list' (bug#73404).
(treesit-forward-sexp-list, treesit-forward-list):
Replace body with a call to the shared implementation
'treesit--forward-list-with-default' using the
corresponding default function as an argument.
João Távora [Mon, 6 Jan 2025 10:47:13 +0000 (10:47 +0000)]
Eglot: new eglot--format to fix quote substitution woes (bug#73472)
* lisp/progmodes/eglot.el (eglot--guess-contact): Use eglot--format.
(eglot--format): New helper.
(eglot--error, eglot--message, eglot--warn)
(eglot--apply-text-edits, eglot-rename): Use eglot--format.
Peter Oliver [Tue, 16 Jul 2024 23:06:02 +0000 (00:06 +0100)]
Try harder to stabilize dired-test-bug27243-02
* test/lisp/dired-tests.el (dired-test-bug27243-02): Don't rely on the
expected point, since columns will move if the size of the parent directory
changes order of magnitude. (Bug#72120)
w08r [Thu, 19 Dec 2024 09:53:02 +0000 (09:53 +0000)]
Enable extra flags in 'go-ts-mode' test commands
* lisp/progmodes/go-ts-mode.el (go-ts-mode-test-flags):
(go-ts-mode--get-test-flags): New custom variable and function
for controlling test behaviour.
(go-ts-mode--compile-test): Updated to use new test flags
variable for passing extra information to the go test command
line.
(go-ts-mode-test-this-package): Updated to use new test flags
variable for passing extra information to the go test command
line. Removed incorrect use of -run flag.
* etc/NEWS: Announce the new user option. (Bug#74786)
Eli Zaretskii [Sun, 5 Jan 2025 10:40:39 +0000 (12:40 +0200)]
Allow to remap 'header-line' face
* src/xfaces.c (realize_basic_faces): Bind 'face-remapping-alist'
to nil while realizing basic faces.
(lookup_basic_face): Force realizing a face whose 'inherit'
attribute is non-nil. (Bug#73862)
(treesit-show-paren-data--categorize): Use 'treesit-thing-defined-p'
to check if the thing exists for the language at POS before calling
'treesit-parent-until' that raises an error for an undefined thing.
(treesit-thing-defined-p): Add the alias signature to the docstring.
Yuan Fu [Sat, 4 Jan 2025 19:53:39 +0000 (11:53 -0800)]
Fix tsx-ts-mode syntax propertize function (bug#73978)
* lisp/progmodes/typescript-ts-mode.el:
(tsx-ts--syntax-propertize-captures): Apply punctuation syntax
on balanced pairs, instead of using string syntax.
Use 'treesit-thing-next' and 'treesit-thing-prev' with
'treesit-node-named' to transpose named siblings that leaves the right
punctuation in anonymous nodes between named siblings. Fall back
to 'transpose-sexps-default-function' inside strings and comments.
(treesit-node-named): New helper function.
Jared Finder [Thu, 2 Jan 2025 06:36:25 +0000 (22:36 -0800)]
Don't always enable xterm-mouse-mode (bug#74833)
Many terminals set the environment variable TERM to "xterm" even when they
don't support all functionality in xterm. This means that enabling
xterm-mouse-mode can break critical editing workflows like copy/paste. This
adds checks for the specific terminal Emacs is run in and only enables
xterm-mouse-mode on terminals knows to support all critical editing workflows.
* etc/NEWS: Update announcement
* lisp/term/xterm.el (xterm--auto-xt-mouse-allowed-names)
(xterm--auto-xt-mouse-allowed-types): New variables to control
what terminals automatically enable xterm-mouse-mode.
(xterm--report-background-handler, xterm--version-handler): Use
xterm--read-string.
(xterm--read-string, xterm--query-name-and-version): New
function.
(xterm--init): Check what terminal is running and if
xterm-mouse-mode was manually called.
* lisp/xt-mouse.el (xterm-mouse-mode-called): New variable.
(xterm-mouse-mode): Set xterm-mouse-mode-called. Mention
automatic call by xterm--init. Delete outdated comment text.
Eli Zaretskii [Sat, 4 Jan 2025 12:44:10 +0000 (14:44 +0200)]
Update eln-cache when --init-directory is used
* lisp/startup.el (normal-top-level): Update eln-cache after
'user-emacs-directory' is set by --init-directory. Patch by
Jordan Isaacs <jordan@snowytrees.dev>. (Bug#75022)
Hong Xu [Thu, 19 Dec 2024 22:33:35 +0000 (14:33 -0800)]
Use `keymap*-set' over `global-set-key'/`define-key' in elisp intro
* doc/lispintro/emacs-lisp-intro.texi (Key Bindings): Since
`global-set-key' and `define-key' are considered legacy, we encourage
`keymap-global-set' and `keymap-set' now. (Bug#74999)
Eli Zaretskii [Sat, 4 Jan 2025 10:51:40 +0000 (12:51 +0200)]
Fix mouse clicks on characters with parenthesis syntax
* lisp/mouse.el (context-menu-region, mouse-skip-word)
(mouse-start-end): Use 'syntax-after' instead of 'char-syntax', to
pay attention to 'syntax-table' text properties. (Bug#74415)
Yuan Fu [Sat, 4 Jan 2025 05:39:32 +0000 (21:39 -0800)]
; Fix typo in treesit-explore-mode
* lisp/treesit.el (treesit-explore-mode): We added the hook to
kill-buffer-hook, so make sure to remove it from
kill-buffer-hook, not post-command-hook.
Stefan Monnier [Fri, 3 Jan 2025 18:24:26 +0000 (13:24 -0500)]
(mpc-cmd-find): Try and fix bug#41493
* lisp/mpc.el (mpc--proc-alist-to-alists): Don't presume that we
have either `directory` or `file` entries, instead allow both at
the same time.
(mpc-cmd-find) <Directory>: Don't presume that `directory`
entries have no associated data, so throw them away only after
having parsed them with `mpc--proc-alist-to-alists`.
On the latest update of the grammar expressions were added and won't be
seen as directives anymore.
* lisp/progmodes/heex-ts-mode.el
(heex-ts--sexp-regexp): Match on expression as well.
(heex-ts--indent-rules): Indent on expression end. (Bug#75191)
* test/lisp/progmodes/heex-ts-mode-resources/indent.erts: Add expression
indent test.
Stefan Kangas [Fri, 3 Jan 2025 06:50:07 +0000 (07:50 +0100)]
Improve temporary file handling in browse-url
* lisp/net/browse-url.el (browse-url-delete-temp-file): Don't add
to kill-buffer-hook on top level.
(browse-url--temp-file-setup): New macro to set 'kill-buffer-hook'
buffer-locally to above function when creating a temporary file. Use
stricter permissions to protect user privacy on multi-user systems.
(browse-url-of-file, browse-url-of-buffer): Use above new macro.
(browse-url-delete-temp-file): Simplify calling convention by removing
unused argument.
Stefan Kangas [Fri, 3 Jan 2025 03:08:44 +0000 (04:08 +0100)]
Remove gnudoit support from browse-url.el
* lisp/net/browse-url.el (browse-url-gnudoit-program)
(browse-url-gnudoit-args, browse-url-w3-gnudoit): Remove support
for gnudoit, obsolete since Emacs 25.1.
Stefan Monnier [Thu, 2 Jan 2025 19:58:10 +0000 (14:58 -0500)]
(describe-variable): Fix bug#73872
* lisp/help-fns.el (describe-variable): Put a `syntax-table` property
on the printed value for better navigation. Remove `set-syntax-table`
since `lisp-data-mode` already did it.
(describe-variable): Remove `set-syntax-table`, not needed any more.
* lisp/help-mode.el (help-mode-syntax-table): `;` shouldn't start a comment.
(help-make-xrefs): Use `with-syntax-table`.
Paul Eggert [Thu, 2 Jan 2025 19:29:26 +0000 (11:29 -0800)]
admin/merge-gnulib now warns if module lists change
From suggestions by Eli Zaretski and Stefan Kangas in:
https://lists.gnu.org/r/emacs-devel/2025-01/msg00036.html
https://lists.gnu.org/r/emacs-devel/2025-01/msg00037.html
* admin/merge-gnulib: For style consistency,
prefer ‘[ EXPR ]’ to ‘test EXPR’ and prefer -e to -f.
Fix bug that forgot to clean lib directory if it’s ./lib.
Check for lib/gnulib.mk.in, which we used directly, not ‘configure’.
(LC_ALL): Set to C.
(autogen): New function, to make it clearer to user when
commands are operating in some other directory.
(get_module_list): New function.
(old_modules, new_modules): New vars.
If they differ, issue a warning.
Roland Winkler [Thu, 2 Jan 2025 05:09:58 +0000 (23:09 -0600)]
Provide more flexibility for definition of BibTeX entries.
* lisp/textmodes/bibtex.el (bibtex-aux-opt-alist): Rename from
bibtex-user-optional-fields.
(bibtex-BibTeX-entry-alist, bibtex-biblatex-entry-alist): Permit
aliases that inherit their definition from another entry.
(bibtex-BibTeX-aux-entry-alist, bibtex-biblatex-aux-entry-alist)
(bibtex-BibTeX-aux-opt-alist, bibtex-biblatex-aux-opt-alist): New
user variables.
(bibtex-entry-alist): Honor these new variables.
(bibtex-field-alist): New function.
(bibtex-include-OPTkey): Default changed to nil, declared
obsolete. Use bibtex-aux-opt-alist instead.
(bibtex-set-dialect): Use cl-flet and bibtex-field-alist.
(bibtex-dialect-select-map): New variable.
(bibtex-init-dialect): New function.
(bibtex-field-list): Simplify.
(bibtex-print-help-message): Bug fix.
Alan Mackenzie [Tue, 31 Dec 2024 18:39:57 +0000 (18:39 +0000)]
CC Mode: Fix various minor indentation bugs
As part of this, introduce a second anchor point to the
syntactic symbols brace-list-intro and enum-intro, the position
of the opening brace.
* lisp/progmodes/cc-align.el
(c-lineup-item-after-paren-at-boi): New function.
* /lisp/progmodes/cc-engine.el
(c-foreign-truncate-lit-pos-cache)
(c-foreign-init-lit-pos-cache): Use
c-truncate-lit-pos/state-cache in place of an older function.
(c-no-bracelist-cache): Update its definition to exclude
conses.
(c-strip-conses): New function.
(c-inside-bracelist-p): Use c-strip-conses.
(c-add-stmt-syntax): In the "go out a block" loop, go out of a
brace at BOI when there's non-whitespace text after it.
Refactor an `if' form containing a cond form into a cond form.
Add the new second second anchor point into syntactic contexts
with brace-list-intro and enum-intro. Anchor brace-list-close
and enum-close elements on the individual declarations in
struct, etc., variable declarations.
(c-guess-basic-syntax, CASE 20): Use the new constraint-cont
syntactic symbol.
(c-guess-basic-syntax, CASE 9B): Anchor brace-list-close and
enum-close elements on the individual declarations in struct,
etc., variable declarations.
(c-guess-basic-syntax, CASEs 9C, 9D): Add the new second anchor
point into brace-list-intro and enum-intro syntactic contexts.
* lisp/progmodes/cc-mode.el (c-locate-first-punctuation-prop):
New function.
(c-depropertize-CPP): Use c-locate-first-punctuation-prop.
* lisp/progmodes/cc-vars.el (c-offsets-alist): Amend the
entries for constraint-cont, brace-list-intro, and enum-intro,
using c-lineup-item-after-paren-at-boi.
* doc/misc/cc-mode.texi (List Line-Up): Add a description of
c-lineup-item-after-paren-at-boi.
* lisp/treesit.el (treesit-forward-sexp-list): Rewrite to support
the value of ARG more than 1. In this case every step moves forward
either over the next treesit-based list or over the syntax-based symbol.
(treesit-down-list, treesit-up-list): Rewrite to support the fallback
to the syntax-based navigation while inside the treesit-based list.
Also use a loop for ARG more than 1 (bug#73404).
Juri Linkov [Mon, 30 Dec 2024 17:54:39 +0000 (19:54 +0200)]
* lisp/treesit.el (treesit-show-paren-data--categorize): Fix it.
Copy the implementation of treesit-parent-until here, and call
its treesit-node-match-p with the argument IGNORE-MISSING set to t
that causes it to fail silently instead of raising an error when
the predicate 'sexp-list' is not defined in an embedded language.
(treesit-major-mode-setup): Set show-paren-data-function to
treesit-show-paren-data only when 'sexp-list' thing is defined
that is used by treesit-show-paren-data--categorize (bug#75198).
Yuan Fu [Mon, 30 Dec 2024 08:21:55 +0000 (00:21 -0800)]
Make typescript-ts-mode work with latest grammar
* lisp/progmodes/typescript-ts-mode.el:
(tsx-ts-mode--font-lock-compatibility-bb1f97b): Return dummy
query when neither query works. In latest grammar, neither will
work, because typescript grammar doesn't include jsx grammar
anymore.
Yuan Fu [Mon, 30 Dec 2024 08:14:37 +0000 (00:14 -0800)]
Generate compatibility report for multiple Emacs versions
* admin/tree-sitter/compat-template.html: Update template.
* admin/tree-sitter/treesit-admin.el:
(treesit-admin--builtin-language-sources): Add sources.
(treesit-admin--builtin-modes): New variable.
(treesit-admin--verify-major-mode-queries): Don't need to pass
LANGS argument anymore.
(treesit-admin-verify-major-mode-queries): Move, and use
treesit-admin--builtin-modes.
(treesit-admin--mode-languages): Set some variables so it gets
all the languages.
(treesit-admin--find-latest-compatible-revision): Also return
commit timestamp.
(treesit-admin--generate-compatibility-report): New parameter
EMACS-EXECUTABLES. Support generating report for multiple Emacs
versions.
* lisp/treesit.el (treesit--language-git-timestamp): New function.
Yuan Fu [Sun, 29 Dec 2024 08:31:37 +0000 (00:31 -0800)]
Add treesit-admin-generate-compatibility-report
This function can generate a HTML report on latest compatible
grammar versions for each major mode.
* admin/tree-sitter/compat-template.html: Update.
* admin/tree-sitter/treesit-admin.el:
(treesit-admin--validate-mode-lang): Change so that emacs 30 can
also run it.
(treesit-admin--find-latest-compatible-revision): Support
running checks with a different Emacs executable.
(treesit-admin--generate-compatibility-report): New function.
This function computes the latest compatible grammar version for
each major mode.
* admin/treesit-admin.el (treesit-admin-file-name): Move.
(treesit-admin--compat-template-file-name): New variable.
(treesit-admin--mode-languages): New function.
(treesit-admin--find-latest-compatible-revision): Return a plist
instead.
(treesit-admin--last-compatible-grammar-for-modes): New function.
This function can find the last grammar revision that is
compatible with a major mode.
* admin/treesit-admin.el (treesit-admin-file-name): New
variable.
(treesit-admin--validate-mode-lang):
(treesit-admin--find-latest-compatible-revision): New functions.
Yuan Fu [Sat, 28 Dec 2024 22:54:17 +0000 (14:54 -0800)]
Refactor treesit-admin--verify-major-mode-queries
Make treesit-admin--verify-major-mode-queries use
treesit--install-language-grammar-1, rathre than the interactive
command treesit-install-language-grammar.
* admin/treesit-admin.el:
(treesit-admin--verify-major-mode-queries): Add parameter
SOURCE-ALIST. Use treesit--install-language-grammar-1.
(treesit-admin-verify-major-mode-queries): Pass
treesit-admin--builtin-language-sources to
treesit-admin--verify-major-mode-queries.
* lisp/treesit.el (treesit-install-language-grammar): Don't
return revision of the git repo.
Yuan Fu [Sat, 28 Dec 2024 22:41:55 +0000 (14:41 -0800)]
Refactor treesit--install-language-grammar-1
Separate treesit--install-language-grammar-1 into two functions,
one clones the repository, the other builds and installs the
grammar.
* lisp/treesit.el (treesit--install-language-grammar-1):
Refactor out treesit--build-grammar.
(treesit--build-grammar): New function.
(treesit--language-git-revision): Now takes REPO-DIR as an
argument.
Juri Linkov [Sun, 29 Dec 2024 18:08:11 +0000 (20:08 +0200)]
Treesit support for show-paren-mode (bug#75122)
* lisp/treesit.el (treesit-show-paren-data--categorize):
New internal function.
(treesit-show-paren-data): New function.
(treesit-major-mode-setup): Set 'show-paren-data-function' to
'treesit-show-paren-data'.