Move to start of current header in diff-{file,hunk}-prev
If point was after a file or hunk header, the diff-file-prev and
diff-hunk-prev commands would move to the start of that header.
But if point was *within* the header, they would not move, and
would report "No previous file" or "No previous hunk". This
differs from the behavior of most other movement commands,
e.g. backward-sexp or backward-sentence.
This commit fixes diff-file-prev and diff-hunk-prev, as well as
other easy-mmode-define-navigation BASE-prev commands. Now
these commands move to the start of the containing "thing" just
like other movement commands.
* lisp/emacs-lisp/easy-mmode.el (easy-mmode--prev):
Move to start of current match first. (bug#73172)
* etc/NEWS: Document the behavior change.
Move easy-mmode-define-navigation logic to helper functions
The functions defined by easy-mmode-define-navigation are useful
even if the easy-mmode-define-navigation macro is not used.
Let's take a step towards exposing them by moving them out as
helpers.
This also makes the macro much easier to modify and work on.
* lisp/emacs-lisp/easy-mmode.el (easy-mmode--prev)
(easy-mmode--next): Add (bug#73172).
(easy-mmode-define-navigation): Use easy-mmode--prev and
easy-mmode--next.
Sean Whitton [Tue, 24 Sep 2024 08:38:43 +0000 (09:38 +0100)]
New command diff-revert-and-kill-hunk
* lisp/vc/diff-mode.el (diff-revert-and-kill-hunk): New
command (bug#73407).
(diff-ask-before-revert-and-kill-hunk): New user option.
(diff-apply-buffer): New optional BEG, END and REVERSE
arguments. Return nil if buffers were saved, or the number of
failed applications.
(diff-mode-map): Bind the new command to C-c M-r.
(diff-mode-menu): New entry for the new command.
* doc/emacs/files.texi (Diff Mode):
* etc/NEWS: Document the change.
Add '(car pattern)' as the LIGHTER argument of 'highlight-regexp'.
This fixes the case when in a file buffer with fundamental-mode:
`C-s M-s ' the M-s h r RET`, revert the buffer with 'C-x x g',
get the prompt for unhighlight with 'M-s h u'. This showed
a raw regexp instead of the human-readable lighter (bug#57534).
Alan Mackenzie [Tue, 24 Sep 2024 20:45:29 +0000 (20:45 +0000)]
CC Mode: Separate indentation of enums from that of brace lists
This will allow enums to be indented as in the GNU coding
standards without affecting brace lists.
* lisp/progmodes/cc-align.el
(c-lineup-arglist-intro-after-paren)
(c-lineup-arglist-close-under-paren)
(c-lineup-whitesmith-in-block)
(c-lineup-after-whitesmith-blocks): Amend doc strings to
indicate they can be used for enum-* syntactic symbols too.
* lisp/progmodes/cc-engine.el (c-looking-at-decl-block)
(c-backward-typed-enum-colon, c-backward-over-enum-header):
Rename c-after-brace-list-key to c-after-enum-list-key and
c-brace-list-key to c-enum-list-key.
(c-at-enum-brace): New function.
(c-inside-bracelist-p): Don't check for enums any more.
(c-add-stmt-syntax): New cond arm for enums.
(c-guess-continued-construct CASE B.6) New code for enum-open.
(c-guess-basic-syntax CASE 5A.3, CASE 7B, CASE 9, CASE 9B)
(CASE 9C, CASE 9D): Use the new function c-at-enum-brace, and
use enum-* syntactic symbols rather than brace-list-* ones
where appropriate.
(c-used-syntactic-symbols): New dynamic variable.
(c-evaluate-offset): Add handling for a different syntactic
symbol as the cdr of a c-offsets-alist element.
* lisp/progmodes/cc-fonts.el (c-get-fontification-context):
Add a call to c-at-enum-brace since c-inside-bracelist-p no
longer handles enums.
(c-font-lock-enum-body, c-font-lock-enum-tail): Condense calls
to c-backward-over-enum-header to c-at-enum-brace.
(c-basic-matchers-after): Replace a c-brace-list-decl-kwds with
c-enum-list-kwds.
* lisp/progmodes/cc-langs.el (c-enum-list-kwds)
(c-enum-list-key): New names for c-brace-list-decl-kwds and
c-brace-list-key.
(c-after-enum-list-kwds, c-after-enum-list-key): New names for
c-after-brace-list-decl-kwds and c-after-brace-list-key.
(c-enum-list-key, c-after-enum-list-key): Add code to
use a value of an old name, should a derived mode still use
that.
(c-defun-type-name-decl-kwds, c-typedef-decl-kwds)
(c-typeless-decl-kwds, c-prefix-spec-kwds)
(c-brace-id-list-kwds, c-enum-clause-introduction-re): Use
c-enum-list-kwds rather than c-brace-list-decl-kwds.
* lisp/progmodes/cc-styles.el (c-read-offset): Add "a
syntactic symbol" into an error message text.
* lisp/progmodes/cc-vars.el (c-valid-offset): Allow for a
syntactic symbol as the parameter.
(c-offsets-alist): Add new syntactic symbols enum-open,
enum-close, enum-intro, and enum-entry.
* doc/misc/cc-mode.texi (Syntactic Symbols): Add a note that
anchor points are briefly documented in cc-vars.el. Correct
the suffix "-block-intro" to "-intro". Remove "an enum or"
from the descriptions of the brace-list-* syntactic symbols.
Add in new descriptions for the enum-* syntactic symbols.
(Brace List Symbols): Remove references to enums. Add a note
that enums are no longer brace-lists.
(Enum Symbols): A new subsection documenting the new enum-*
syntactic symbols.
(c-offsets-alist): Document the new possibility, syntactic
symbol, for the cdr of an alist entry.
(Brace/Paren Line-Up, List Line-Up): Note that the new enum
syntactic symbols can be handled by these lineup functions.
Pass all dropped files to 'dnd-handle-multiple-urls' in
one call instead on doing multiple calls (Bug#73258).
* lisp/term/w32-win.el (w32-dropped-file-to-url): New function to
convert file name to a url for dnd.
(w32-handle-dropped-file): Changed to use 'w32-dropped-file-to-url'.
(w32-drag-n-drop): Changed to pass all files to
'dnd-handle-multiple-urls'/
Alan Mackenzie [Sat, 21 Sep 2024 16:46:32 +0000 (16:46 +0000)]
CC Mode: fix minor errors in the fontification of enums.
1: Fix the typing of a space on the { line in an enum
specification which is the first item in a buffer. This
defontified the enum's identifiers.
2: Fix the typing of a space on the line of the enum's last
identifier. This defontified that identifier for
jit-lock-context-time.
* lisp/progmodes/cc-engine.el (c-forward-declarator): Cease
rejecting the identifier if there are no further tokens before
LIMIT.
* lisp/progmodes/cc-mode.el (c-fl-decl-start): Accept a
backward search as succeeding if it hits point-min.
Manuel Giraud [Sat, 21 Sep 2024 12:51:21 +0000 (14:51 +0200)]
Don't activate midnight-mode when loading 'midnight'
* lisp/midnight.el (midnight-mode): Call 'midnight-delay-set' again
when the mode is activated.
(midnight-delay-set): Only start the timer if the mode is turned
on. (Bug#73291)
* etc/NEWS: Document the change in behaviour.
Stefan Kangas [Sat, 21 Sep 2024 12:13:47 +0000 (14:13 +0200)]
Add all exceptions up to Python 3.13 as keywords
* lisp/progmodes/python.el
(python-font-lock-keywords-maximum-decoration)
(python--treesit-exceptions): Add all built-in exceptions in Python 3.13
as keywords. Missing from the list was "BaseExceptionGroup",
"EncodingWarning", "ModuleNotFoundError", and "PythonFinalizationError".
Stefan Monnier [Thu, 19 Sep 2024 15:50:26 +0000 (11:50 -0400)]
Fix font-lock of last character before EOB under 'whitespace-mode'
* lisp/whitespace.el (whitespace-color-on): Don't use OVERRIDE in
font-lock-keywords; instead, use 'prepend' in the call to
'font-lock-add-keywords'. (Bug#73332)
Eli Zaretskii [Sat, 21 Sep 2024 10:41:21 +0000 (13:41 +0300)]
Fix 'whitespace-mode' with 'missing-newline-at-eof'
* lisp/whitespace.el (whitespace-post-command-hook): Refontify
when point moves if 'missing-newline-at-eof' is in
'whitespace-active-style'. (Bug#73332)
Add user option to enable Doxygen syntax highlighting (bug#72814)
Both 'c-ts-mode' and 'java-ts-mode' have a new user option,
'c-ts-mode-enable-doxygen' and 'java-ts-mode-enable-doxygen'
(defaults to nil) which allow to enable syntax highlighting
of comment blocks based on the Doxygen grammar.
* lisp/progmodes/c-ts-mode.el: Add the 'c-ts-mode-enable-doxygen'
user option variable to disable doxygen grammar.
Notifies the user if doxygen grammar is not available.
* lisp/progmodes/c-ts-mode.el (c-ts-mode, c++-ts-mode): Use the
new 'c-ts-mode-enable-doxygen' option.
* lisp/progmodes/java-ts-mode.el: Add the
'java-ts-mode-enable-doxygen' user option variable to disable
doxygen grammar. Notifies the user if doxygen grammar is not
available.
* lisp/progmodes/java-ts-mode.el (java-ts-mode): Use the new
'java-ts-mode-enable-doxygen' option.
Eli Zaretskii [Sat, 21 Sep 2024 09:30:49 +0000 (12:30 +0300)]
Fix 'regexp-replace' in WDired
* src/search.c (Freplace_match): Remove the test that
search_regs.num_regs != num_regs. It is deemed unnecessary now,
and could produce false positives. (Bug#73018)
Yuan Fu [Sat, 21 Sep 2024 03:40:26 +0000 (20:40 -0700)]
Fix treesit--merge-ranges (bug#73324)
* lisp/treesit.el (treesit--merge-ranges): Make sure that old
ranges that intersects with START-END are actually discarded.
* test/src/treesit-tests.el (treesit-range-merge): New test.
Stefan Kangas [Sat, 21 Sep 2024 01:41:26 +0000 (03:41 +0200)]
; Delete bug fix from etc/NEWS
* etc/NEWS: Delete bug fix item. No correct program will see a
difference in behavior; at worst, the error message when calling
`(error)` is now better.
Reported by Mattias Engdegård <mattias.engdegard@gmail.com>.
Stefan Kangas [Sat, 21 Sep 2024 00:19:53 +0000 (02:19 +0200)]
Fix midnight-mode documentation
* lisp/midnight.el (Commentary): Document that 'midnight-mode' should be
enabled using the function, instead of by merely loading the library.
In Emacs 31, doing the latter will no longer work. (Bug#73291)
Instead of setting the highlight overlay on every line in the selection,
only do so on the window-height worth of lines closest to point because
the rest aren't likely to be visible.
This makes a massive difference for tall rectangular selections which
previously were so slow as to be unusable.
(Tall selections are still slow if `select-active-regions` is non-nil,
but that is something that users can actually do something about.)
* lisp/rect.el (rectangle--highlight-for-redisplay)
(rectangle--unhighlight-for-redisplay):
Replace call to `apply-on-rectangle`, which operates on every line,
with a loop over an approximate screenful.
Extend the `rectangle` overlay list structure with a value for point,
because `exchange-point-and-mark` must trigger a recomputation of
highlight overlays despite the selection not actually changing.
Spencer Baugh [Thu, 12 Oct 2023 22:01:46 +0000 (18:01 -0400)]
Support numeric indexing in let-alist
let-alist is very useful. But sometimes an alist contains a list in
the middle, which contains yet more alists. Previously, this was
somewhat painful to deal with, and required something like:
Paul Eggert [Wed, 18 Sep 2024 16:18:29 +0000 (09:18 -0700)]
yes-or-no-p now uses blankp rather than SYNTAX
* src/fns.c: Do not include syntax.h; no longer needed.
(Fyes_or_no_p): Use blankp rather than SYNTAX to check whether the
prompt ends in nonspace. That way, the test doesn’t depend on the
current buffer.
Yuan Fu [Wed, 18 Sep 2024 04:17:13 +0000 (21:17 -0700)]
Conservative heuristic for tree-sitter parser ranges (bug#73324)
* src/treesit.c (treesit_sync_visible_region): If the parser's original
ranges don't overlap with visible region, give it a zero range, rather
than don't set any range.
* test/src/treesit-tests.el (treesit-range-fixup-after-edit): Test new
behavior.
Enable GC_REMEMBER_LAST_MARKED by default (it was disabled in Emacs 29)
to make it easier to debug difficult-to-reproduce GC problems
encountered by users. This increases GC costs by about 5 %, which can
be avoided by turning the mark trace buffer back off using the new
--disable-gc-mark-trace option.
See discussion at
https://lists.gnu.org/archive/html/emacs-devel/2024-09/msg00240.html
* configure.ac (--disable-gc-mark-trace): New config option.
* etc/NEWS: Mention it.
* src/alloc.c: Enable it by default and avoid a compiler warning.
Yuan Fu [Sun, 15 Sep 2024 07:24:03 +0000 (00:24 -0700)]
Fix treesit_sync_visible_region's range fixup code (bug#73264)
new_ranges_head
|
v
( )->( )->( )->( )->( )
^ ^
| |
| lisp_ranges (loop head)
|
prev_cons -> set cdr to nil to cut of the rest
result:
( )->( )
* src/treesit.c (treesit_sync_visible_region): Cut off this cons and the
rest, not set the current range's end to nil.
* test/src/treesit-tests.el:
(treesit-range-fixup-after-edit): Add tests for all cases.