1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00
Commit graph

268 commits

Author SHA1 Message Date
Sean Whitton
022facd986 * lisp/vc/diff-mode.el (diff-revert-and-kill-hunk): Fix finding END. 2025-12-05 17:05:47 +00:00
Sean Whitton
d63ed68684 * lisp/vc/diff-mode.el (diff-revert-and-kill-hunk): Fix killing. 2025-12-04 15:40:11 +00:00
Sean Whitton
c499c2f67b * lisp/vc/diff-mode.el (diff-filename-drop-dir): Match backslashes. 2025-11-29 18:21:31 +00:00
Sean Whitton
1677c4681a Handle copying additions & removals between working trees
* lisp/vc/diff-mode.el (diff-file-kill): New optional DELETE
parameter.
(diff-kill-creations-deletions):
* lisp/vc/vc.el (vc--fileset-by-state): New functions.
(diff-kill-creations-deletions, diff-filename-drop-dir)
(diff-hunk-file-names, diff-file-next, diff-hunk-header-re)
(vc-dir-resynch-file): Declare.
(vc--apply-to-other-working-tree): Handle copying and moving
files in the added, removed, missing and unregistered states.
* test/lisp/vc/vc-tests/vc-tests.el
(vc-test--apply-to-other-working-tree): New test.
2025-11-29 14:35:39 +00:00
Sean Whitton
304d4435b1 Make diff-revert-and-kill-hunk consider an active region
* lisp/vc/diff-mode.el (diff-revert-and-kill-hunk): When the
region is active, operate on all hunks it overlaps.
* doc/emacs/files.texi (Diff Mode):
* etc/NEWS: Document the change.
2025-11-25 21:07:04 +00:00
Sean Whitton
449e15de5b ; * lisp/vc/diff-mode.el (diff-goto-source): Revise docstring again. 2025-11-25 15:53:15 +00:00
Sean Whitton
59e8b7267f Make diff-apply-hunk consider an active region
* lisp/vc/diff-mode.el (diff-apply-buffer): New 'no-save'
meaning for fourth optional argument.  Reserve other non-nil
values for this argument.  Use ngettext for one message.
(diff-apply-hunk): If the region is active, apply all hunks that
the region overlaps, like diff-apply-buffer.
* doc/emacs/files.texi (Diff Mode):
* etc/NEWS: Document the change to diff-apply-hunk.
2025-11-25 14:53:19 +00:00
Sean Whitton
3f6c7d1bfb ; diff-mode-el: Improve docstrings re diff-jump-to-old-file. 2025-11-25 14:06:29 +00:00
Sean Whitton
11b68c6223 New commands to rewind decentralized VCS branches
* lisp/vc/vc.el (vc--remove-revisions-from-end): New function.
(vc-uncommit-revisions-from-end, vc-delete-revisions-from-end):
* lisp/vc/log-view.el (log-view-uncommit-revisions-from-end)
(log-view-delete-revisions-from-end): New commands (bug#79408).
(log-view-mode-map): Bind them.
* doc/emacs/maintaining.texi (VC Change Log):
* doc/emacs/vc1-xtra.texi (VC Auto-Reverting):
* etc/NEWS: Document them.
2025-11-23 18:36:22 +00:00
Sean Whitton
3ae79b7c05 diff-apply-hunk: Avoid display-buffer-overriding-action
* lisp/vc/diff-mode.el (diff-apply-hunk): Use ACTION argument to
display-buffer instead of display-buffer-overriding-action.
2025-11-18 12:56:25 +00:00
Sean Whitton
0d4741ec92 diff-apply-hunk: Don't display BUF in the selected window
* lisp/vc/diff-mode.el (diff-apply-hunk): Don't display BUF in
the selected window.
2025-11-14 13:00:13 +00:00
Sean Whitton
5dfcba699e Revised bindings for diff-revert-and-kill-hunk
* lisp/vc/diff-mode.el (diff-mode-shared-map): Bind
diff-revert-and-kill-hunk to 'u'.
(diff-mode-map): Replace binding for diff-revert-and-kill-hunk
with 'C-c M-u'.
* doc/emacs/files.texi (Diff Mode):
* etc/NEWS: Document the change.
2025-11-13 16:22:20 +00:00
Juri Linkov
e2531721b4 * lisp/vc/diff-mode.el (diff-changed-unspecified): Restore old colors.
Restore yellow colors previously used in the 'diff-changed' face.
Copy color values from 'smerge-base'.  This will distinguish them
from grey 'diff-file-header' and 'diff-hunk-header' in context diffs.
2025-11-09 20:14:12 +02:00
Stefan Monnier
5c18d23d66 (diff-refine-threshold): New custom var (bug#79546)
Avoid getting stuck waiting for `diff` to refine big hunks.

* lisp/vc/diff-mode.el (diff-refine-threshold): New custom var.
(diff--refine-hunk): Add arg `skip-if-large` and use that new var if
the arg says so.
(diff-refine-hunk): Add arg `skip-if-large`.
(diff-auto-refine-mode, diff-next/prevhunk, diff--font-lock-refined):
Use it.
2025-11-07 11:13:27 -05:00
Juri Linkov
b0078bfa15 Improve color contrast of refine-related diff faces on dark backgrounds
* lisp/vc/diff-mode.el (diff-refine-removed, diff-refine-added):
* lisp/vc/ediff-init.el (ediff-fine-diff-A, ediff-fine-diff-B):
* lisp/vc/smerge-mode.el (smerge-refined-removed, smerge-refined-added):
Lower the dominant component of RGB colors from "aa" to "88" (bug#79633).
2025-10-16 20:05:41 +03:00
Sean Whitton
9ccef794a8 VC: New commands for cherry-picking (bug#79408)
* lisp/vc/diff-mode.el (diff-buffer-file-names): New function.
* lisp/vc/log-view.el (vc--pick-or-revert)
(vc--prompt-other-working-tree): Autoload.
(vc-parent-buffer-name, vc-log-short-style)
(vc-print-log-internal): Declare.
(log-view--pick-or-revert): New function.
(log-view-revision-cherry-pick, log-view-revision-revert): New
commands.
(log-view-mode-map, log-view-mode-menu): Bind them.
* lisp/vc/vc-dispatcher.el (vc-start-logentry): If
get-file-buffer returns nil, use the current buffer as the
parent buffer.
* lisp/vc/vc.el (diff-buffer-file-names, diff-reverse-direction):
Declare.
(vc--pick-or-revert): New function.
(vc-revision-cherry-pick, vc-revision-revert): New commands.
* lisp/vc/vc-hooks.el (vc-menu-map): Bind them.
* doc/emacs/maintaining.texi (VC Change Log, VC Undo)
(Copying Between Branches):
* etc/NEWS: Document the new commands.
2025-10-04 18:18:48 +01:00
Sean Whitton
208e80018a New commands to apply changes to other working trees
* lisp/vc/diff-mode.el (diff-apply-buffer): New TEST argument.
* lisp/vc/vc.el (diff-apply-buffer): Declare.
(vc-no-confirm-moving-changes): New user option.
(vc-apply-to-other-working-tree)
(vc-apply-root-to-other-working-tree): New commands.
* lisp/vc/vc-hooks.el (vc-prefix-map): Bind them.
* doc/emacs/vc1-xtra.texi (Other Working Trees):
* etc/NEWS: Document them.
2025-09-16 14:30:02 +01:00
Sean Whitton
15939846a0 Make C-x v w w work in Log View mode, to change working directory
* lisp/vc/diff-mode.el (diff-find-matching-buffer): Rename ...
* lisp/progmodes/project.el
(project-change-to-matching-directory): ... to here.  All uses
changed.
* lisp/vc/log-view.el (project-change-to-matching-directory):
Declare.
(log-view-mode): Use it.
* doc/emacs/vc1-xtra.texi (Other Working Trees): Document the
change.
2025-09-08 11:50:36 +01:00
Sean Whitton
838e8e4140 New project-find-matching-buffer-function for diff-mode
* lisp/vc/diff-mode.el (project-root): Declare.
(diff-find-matching-buffer): New function.
(diff-mode): Use it.
* doc/emacs/vc1-xtra.texi (Other Working Trees): Document
'C-x v w w' in diff-mode buffers.
2025-09-01 15:27:57 +01:00
john muhl
ff05a689e3 (diff--font-lock-prettify): Fix fringe width test
* lisp/vc/diff-mode.el (diff--font-lock-prettify):
Use 'window-fringes' instead of the 'left-fringe' frame parameter
since the former returns an integer on both GUI and TTY frames.
2025-08-16 04:59:49 -04:00
Sean Whitton
c56c56b3c6 Include shorter bindings in diff-mode docstring
* lisp/vc/diff-mode.el (diff-read-only-map): New keymap,
factored out of code modifying minor-mode-map-alist.
(diff-mode): Include bindings from diff-read-only-map in
docstring (bug#34080).
2025-07-19 11:17:25 +01:00
Sean Whitton
94b2a0b2fc Merge from origin/emacs-30
24db9b7962 ; * lisp/vc/diff-mode.el (diff-mode): Scare-quote 'normal'.
756e7e5243 ; * lisp/window.el (window-state-put): Fix a typo (bug#79...
0fb20adf8e ; define-globalized-minor-mode: Fix info node link in doc...
2025-07-16 11:18:41 +01:00
Sean Whitton
24db9b7962 ; * lisp/vc/diff-mode.el (diff-mode): Scare-quote 'normal'. 2025-07-16 11:17:58 +01:00
Sean Whitton
a8309895ae ; * lisp/vc/diff-mode.el (diff-mode-shared-map): Document. 2025-05-13 10:09:26 +01:00
Sean Whitton
4ddafede8d diff-mode-shared-map: Don't inherit from special-mode-map
* lisp/vc/diff-mode.el (diff-mode-shared-map): No longer inherit
from special-mode-map.
(diff-mode-map): Tidy up list of unbindings now that we no
longer need to override any bindings from special-mode-map.
(minor-mode-map-alist): <diff-mode-read-only>: Ensure that the
minor mode keymap continues to inherit from special-mode-map by
calling make-composed-keymap here.

Co-authored-by: Stefan Monnier <monnier@iro.umontreal.ca>
2025-05-12 10:11:18 +01:00
Sean Whitton
5b73625714 diff-mode-map: Unhide some additional M-<foo>
* lisp/vc/diff-mode.el (diff-mode-map): Don't inherit M-?,
M-SPC, M-DEL and M-S-SPC bindings through from special-mode-map.
2025-05-11 11:12:53 +01:00
Juri Linkov
47b075e24b Update the default value of 'diff-outline-regexp'.
* lisp/vc/diff-mode.el (diff-outline-regexp): Change the default value
to match the diff command name in recursive diff.  Move after
'diff-hunk-header-re' variable definition used in the new value.
(diff-setup-buffer-type): Change setq of 'diff-outline-regexp'
to buffer-local (bug#78269).
2025-05-07 09:31:01 +03:00
Juri Linkov
ddc7bd547a Don't ignore errors in diff-syntax-fontify-hunk.
* lisp/nxml/nxml-mode.el (nxml-extend-region):
Protect against error "Invalid search bound (wrong side of point)".

* lisp/vc/diff-mode.el (diff-syntax-fontify-hunk):
Use 'with-demoted-errors' instead of 'ignore-errors'.
2025-05-07 09:20:18 +03:00
Juri Linkov
e5746d3677 * lisp/vc/diff-mode.el (diff-syntax-fontify-hunk): Add 'ignore-errors'. 2025-05-05 19:52:28 +03:00
Tomas Nordin
4980287e08 Teach diff-apply-hunk to handle hunks with empty context
* lisp/vc/diff-mode.el (diff-find-source-location):
Consider the case when there is no diff context above or below
edited lines.  (bug#72556)

* test/lisp/vc/diff-mode-tests.el: Add tests for undoing hunks
from diffs with addtions only in the beginning or end of the
source file.
2025-03-15 04:54:11 +02:00
Sean Whitton
942bb22c9f diff-apply-buffer: Operate on region, add prefix argument
* lisp/vc/diff-mode.el (diff-apply-buffer): Interactively,
operate on an active region.  Reverse-apply hunks with a prefix
argument, like C-u C-c C-a already does.
2025-03-11 19:17:04 +08:00
Stefan Kangas
10abb87f05 Fix fontification outside hunks in Git patches
* lisp/vc/diff-mode.el (diff-font-lock-keywords): Don't fontify lines in
Git patches starting with + or - as added/removed, if they are either
before the first hunk, or in the email signature.  (Bug#75884)
(diff-buffer-type): Move definition up.
(diff--indicator-added-re, diff--indicator-removed-re): New variables.
(diff--git-preamble-end, diff--git-footer-start)
(diff--indicator-matcher-helper, diff--indicator-added-matcher)
(diff--indicator-removed-matcher): New functions.
* test/lisp/vc/diff-mode-tests.el (diff-mode-test-git-patch)
(diff-mode-test-git-patch/before-first-hunk)
(diff-mode-test-git-patch/signature): New tests.
* test/lisp/vc/diff-mode-resources/git.patch: New file.
2025-03-03 18:57:17 +01:00
Stefan Kangas
5397721352 Don't enable minor modes in diff-add-log-current-defuns
* lisp/vc/diff-mode.el (diff-add-log-current-defuns): Don't run mode
hooks when enabling major mode hooks.  That fails if, for example,
paredit-mode is on emacs-lisp-mode-hook and it signaled due to
unbalanced parens.
2025-02-26 04:49:52 +01:00
Stefan Kangas
e60103f130 Prefer incf to cl-incf in vc/*.el
* lisp/vc/diff-mode.el (diff-count-matches):
(diff-fixup-modifs, diff-add-log-current-defuns):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-hooks.el (vc-insert-file):
* lisp/vc/vc.el (vc-print-log-setup-buttons, vc-prepare-patch):
Prefer incf to cl-incf.
2025-02-26 01:48:48 +01:00
Juri Linkov
24e8477aa2 Better support for nil enable-local-variables in vc-find-revision-no-save
* lisp/vc/diff-mode.el (diff-syntax-fontify-props):
* lisp/vc/vc.el (vc-find-revision-no-save):
Use enable-local-variables as is only when it's one of these values:
:safe, :all, or nil.  Otherwise, for all remaining values that query,
use :safe.  Also use non-nil 'find-file' arg of 'normal-mode'.
https://lists.gnu.org/archive/html/emacs-devel/2025-02/msg00897.html
2025-02-24 19:51:13 +02:00
Stefan Kangas
9d7d4db7eb Prefer decf to cl-decf
* lisp/auth-source-pass.el (auth-source-pass--find-match-many):
* lisp/calendar/time-date.el (decoded-time-add)
(decoded-time--alter-month, decoded-time--alter-day):
* lisp/dired.el (dired--move-to-next-line):
* lisp/dom.el (dom-pp):
* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda):
* lisp/emacs-lisp/cl-print.el (cl-print-to-string-with-limit):
* lisp/emacs-lisp/cl-seq.el (cl-fill, cl-replace, cl-substitute):
* lisp/emacs-lisp/comp-cstr.el (comp--range-union)
(comp--range-intersection):
* lisp/emacs-lisp/comp.el (comp-vec-prepend, comp--emit-narg-prologue):
* lisp/emacs-lisp/edebug.el (edebug--strip-instrumentation):
* lisp/emacs-lisp/eldoc.el (eldoc--invoke-strategy):
* lisp/emacs-lisp/pp.el (pp--format-definition):
* lisp/emacs-lisp/smie.el (smie-config--guess-1):
* lisp/eshell/esh-io.el (eshell-close-handle, eshell-set-output-handle):
* lisp/gnus/gnus-async.el (gnus-async-prefetch-article):
* lisp/gnus/gnus-group.el (gnus-group-mark-group)
(gnus-group-yank-group):
* lisp/gnus/gnus-salt.el (gnus-tree-forward-line):
* lisp/gnus/gnus-score.el (gnus-decay-scores):
* lisp/gnus/gnus-srvr.el (gnus-browse-toggle-subscription-at-point):
* lisp/gnus/gnus-sum.el (gnus-build-sparse-threads, gnus-parent-headers)
(gnus-update-marks, gnus-summary-work-articles)
(gnus-summary-refer-parent-article, gnus-summary-next-thread)
(gnus-read-header, gnus-summary-insert-new-articles):
* lisp/gnus/gnus-topic.el (gnus-topic-forward-topic):
* lisp/gnus/gnus.el (gnus-short-group-name):
* lisp/gnus/message.el (message-remove-first-header)
(message-shorten-references, message-insert-screenshot):
* lisp/gnus/mm-url.el (mm-url-insert):
* lisp/gnus/nnselect.el (nnselect-push-info):
* lisp/ibuffer.el (ibuffer-backward-line, ibuffer-forward-line)
(ibuffer-map-lines):
* lisp/icomplete.el (icomplete--render-vertical):
* lisp/image/image-dired-external.el (image-dired-create-thumb-1):
* lisp/image/image-dired.el (image-dired-delete-char):
* lisp/mail/ietf-drums-date.el (ietf-drums-date--tokenize-string):
* lisp/mh-e/mh-utils.el (mh-sub-folders-parse):
* lisp/minibuffer.el (minibuffer-completion-help):
* lisp/mpc.el (mpc-cmd-move, mpc-songpointer-refresh-hairy):
* lisp/net/eww.el (eww-process-text-input):
* lisp/net/pop3.el (pop3-wait-for-messages, pop3-uidl-stat)
(pop3-uidl-dele):
* lisp/net/shr-color.el (shr-color-hue-to-rgb):
* lisp/play/5x5.el (5x5-up, 5x5-left):
* lisp/play/decipher.el (decipher-read-alphabet, decipher--digram-total)
(decipher-analyze-buffer):
* lisp/play/hanoi.el (hanoi-insert-ring, hanoi-move-ring):
* lisp/profiler.el (profiler-format-number)
(profiler-calltree-build-unified):
* lisp/progmodes/antlr-mode.el (antlr-next-rule, antlr-indent-line):
* lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset):
* lisp/progmodes/ebrowse.el
(ebrowse-cyclic-display-next/previous-member-list):
* lisp/progmodes/hideif.el (hif-backward-comment):
* lisp/progmodes/js.el (js-beginning-of-defun, js-end-of-defun)
(js-ts--syntax-propertize):
* lisp/progmodes/typescript-ts-mode.el
(tsx-ts--syntax-propertize-captures):
* lisp/rect.el (rectangle--*-char):
* lisp/term.el (term-emulate-terminal):
* lisp/textmodes/reftex-cite.el (reftex-do-citation):
* lisp/textmodes/reftex-index.el (reftex-index-next-phrase):
* lisp/textmodes/reftex-parse.el (reftex-init-section-numbers):
* lisp/textmodes/reftex-sel.el (reftex-select-unmark):
* lisp/textmodes/reftex.el (reftex-silence-toc-markers):
* lisp/treesit.el (treesit-navigate-thing):
* lisp/vc/diff-mode.el (diff-sanity-check-context-hunk-half,
(diff-sanity-check-hunk):
* lisp/vc/pcvs-util.el (cvs-first):
* lisp/vc/smerge-mode.el (smerge-get-current):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* test/lisp/net/socks-tests.el
(socks-tests-perform-hello-world-http-request):
* test/src/buffer-tests.el (test-overlay-randomly): Prefer decf to
cl-defc in all code where we can.
2025-02-23 00:38:22 +01:00
Stefan Monnier
300bae4f7c Fix some uses of %s for non-strings/names
* lisp/files.el (normal-mode, set-auto-mode--apply-alist):
* lisp/gnus/nnimap.el (nnimap-command):
* lisp/emacs-lisp/bytecomp.el (bytecomp--check-cus-type):
Prefer %S over %s for arbitrary sexps and lists.
2025-02-14 11:25:52 -05:00
Juri Linkov
35fa712690 * lisp/vc/diff-mode.el (diff-mode): Disable view-mode keybindings.
Put the property 'mode-class' with the value 'special' on the symbol
'diff-mode'.  This fixes the case when 'view-read-only' is non-nil
by disabling activation of 'view-mode' that overrides single keys
from 'diff-mode-shared-map' (bug#75993).
2025-02-09 09:40:44 +02:00
Andreas Schwab
a0e1115caa Don't try to unregister tracker ID twice
* lisp/vc/diff-mode.el (diff-minor-mode): Clear
diff--track-changes after unregistering.
2025-02-08 19:39:03 +01:00
Stefan Kangas
7fa975adbc Update copyright year to 2025
Run "TZ=UTC0 admin/update-copyright".
2025-01-02 18:39:42 +01:00
Paul Eggert
4da38c6321 Update copyright year to 2025
Run "TZ=UTC0 admin/update-copyright".
2025-01-01 07:39:17 +00:00
Dmitry Gutov
1374f20491 Fix the regression in dired-backup-diff's diff-goto-source behavior
* lisp/vc/diff-mode.el (diff-find-source-location): Undo part of
the previous change, so that 'reverse' does not affect whether the
"other file" is used (bug#62731).
(diff-apply-hunk): Make that choice here.
2024-10-19 02:26:32 +01:00
Dmitry Gutov
2d139141a6 Support file creation and deletion in diff-apply-hunk
* lisp/vc/diff-mode.el (diff-find-file-name): Allow entering
non-existing file name when the corresponding hunk is of type
"create file" (bug#62731).  Default to file name with deleted
prefix if diff-buffer-type is Git or Hg.  Make sure not to add
such input to diff-remembered-files-alist, it would be hard to
change otherwise in case of typo.
(diff-setup-buffer-type):
Match against the diff header common to 'hg diff' output.
(diff-find-source-location): Look at the other source when the
buffer is applied in reverse.
(diff-apply-hunk): Delect file deletion and pass a different
argument to 'diff-find-source-location' in such case.  Bind
diff-vc-backend to nil to avoid older revision buffer being
returned.  In the end, offer to delete the file if the hunk was of
corresponding type and matched the existing contents.

* etc/NEWS: Mention the new capability.
2024-10-08 02:25:21 +03:00
Juri Linkov
9102f1eaaf * lisp/vc/diff-mode.el (diff-apply-buffer): Add more failures.
Add 'failures' as an argument to the 'message' call.
2024-10-06 20:16:21 +03:00
Sean Whitton
11e7aa75ee ; Rework documentation for diff-delete-other-hunks 2024-10-03 08:50:55 +08:00
Sean Whitton
7aa106b8bf Move error check from vc-next-action to diff-vc-deduce-fileset
* lisp/vc/diff-mode.el (diff-vc-deduce-fileset): Signal
user-error when the buffer is narrowed.
* lisp/vc/vc.el (vc-next-action): Remove code signalling a
user-error when the buffer is narrowed.
2024-10-02 09:22:52 +08:00
Sean Whitton
b64f69f6dc New command diff-delete-other-hunks
* lisp/vc/diff-mode.el (diff-delete-other-hunks): New
command (bug#73387).
(diff-mode-map): Bind the new command to C-c RET n.
(diff-mode-menu): New entry for the new command.
(vc-next-action): Stop, and warn, if the user attempts to commit
a patch from a narrowed buffer (bug#73387).
* doc/emacs/files.texi (Diff Mode):
* etc/NEWS: Document the new command.
2024-10-01 08:56:59 +08:00
Eli Zaretskii
c86e7a29e7 ; Fix documentation of last change
* lisp/vc/diff-mode.el (diff-ask-before-revert-and-kill-hunk): Add
':version' tag.
(diff-revert-and-kill-hunk, diff-apply-buffer): Doc fixes.

* etc/NEWS:
* doc/emacs/files.texi (Diff Mode): Fix last change; add indexing.
2024-09-26 14:24:18 +03:00
Sean Whitton
f2e3e563d4 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.
2024-09-26 11:51:21 +01:00
Eli Zaretskii
f28793822d ; Improve use of ngettext 2024-09-25 20:33:30 +01:00