Commit graph

201 commits

Author SHA1 Message Date
Juri Linkov
d813f71ffe * lisp/vc/diff-mode.el (diff-apply-buffer): New command (bug#66113).
(diff-mode-map): Bind 'diff-apply-buffer' to 'C-c C-m a'.
2023-09-27 20:39:33 +03:00
Robert Pluim
6a677fd3b6 New option 'diff-ignore-whitespace-switches'
Allows specifying the switches to use when ignoring whitespace for
those of us who don't like "-b".

* lisp/vc/diff-mode.el (diff-ignore-whitespace-switches): New defcustom.
(diff-refresh-hunk): Use it when ignoring whitespace.
* doc/emacs/files.texi (Diff Mode): Describe the new option.
* etc/NEWS: Announce the new option.
2023-02-15 15:28:47 +01:00
Robert Pluim
571558e460 Teach 'diff-ignore-whitespace-hunk' how to regenerate all hunks
This implements the request from Bug#58516.

* lisp/vc/diff-mode.el (diff--ignore-whitespace-all-hunks): New
function.  Iterate over all hunks, regenerate ignoring whitespace
changes.
(diff-ignore-whitespace-hunk): Call `diff--ignore-whitespace-all-hunks'
when called with a prefix arg.

* doc/emacs/files.texi (Diff Mode): Describe new functionality.
* etc/NEWS: Announce the change.
2023-02-15 13:51:47 +01:00
Juri Linkov
c1401d1c6c * lisp/vc/diff-mode.el (diff-font-lock-keywords): Check for limit.
This check is necessary since 'diff-beginning-of-hunk' can move
not only backwards, but also forwards (bug#60660).
2023-01-09 09:54:19 +02:00
Eli Zaretskii
cae528457c ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
Juri Linkov
b69bffeec0 * lisp/vc/diff-mode.el (diff-minor-mode-prefix): Replace "ESC" with "\e".
"ESC" looks like an attempt to use kbd syntax in customization.
But actually now 'key-description' is used in 'diff-minor-mode-map'
to convert "\e" to "ESC".
2022-12-28 20:14:43 +02:00
Stefan Kangas
f7ee6609ae ; Fix typos (prefer US spelling) 2022-11-18 13:06:55 +01:00
Philip Kaludercic
1c1aaa0ecd
; Use US spelling docstring
* lisp/vc/diff-mode.el (diff-add-log-use-relative-names): Update docstring.
2022-09-11 13:12:39 +02:00
Lars Ingebrigtsen
0fd24ebc95 Fix diff-mode.el compilation warnings
* lisp/vc/diff-mode.el (diff-auto-refine-mode): Suppress
byte-compile warnings.
2022-09-10 08:01:55 +02:00
Lars Ingebrigtsen
aa02ffb2ab Fix diff-add-log-use-relative-names prompting
* lisp/vc/diff-mode.el (diff-add-log-use-relative-names): Autoload
to avoid prompting when set via dir-locals.
2022-09-08 14:23:21 +02:00
Philip Kaludercic
740a1a3d0e Add new user option 'diff-add-log-use-relative-names'
* .dir-locals.el: Set new option to t
* etc/NEWS: Mention new option.
* lisp/vc/diff-mode.el (diff-add-log-use-relative-names): Add new option.
(diff-add-log-current-defuns): Use new option.
* doc/emacs/maintaining.texi (Log Buffer): Mention new option.
2022-09-08 08:21:15 +02:00
Juri Linkov
4803fba487 'C-x v v' on a diff buffer commits it as a patch (bug#52349)
* lisp/vc/diff-mode.el (diff-vc-deduce-fileset): New function.

* lisp/vc/log-edit.el (log-edit-diff-patch): New function.

* lisp/vc/vc-dispatcher.el (vc-log-edit): Set log-edit-diff-function
to log-edit-diff-patch when vc-patch-string is non-nil.
(vc-start-logentry): New optional arg 'patch-string'.
Set buffer-local 'vc-patch-string' to 'patch-string'.
(vc-dispatcher-browsing): Add (derived-mode-p 'diff-mode).

* lisp/vc/vc-git.el (vc-git-checkin-patch): New function.
(vc-git-checkin): When vc-git-patch-string is non-nil,
use `git apply --cached` to add the patch to the index,
then commit the staged changes.

* lisp/vc/vc.el: New backend function 'checkin-patch'.
(vc-deduce-fileset-1): Call diff-vc-deduce-fileset in diff-mode.
(vc-next-action): For model 'patch' call vc-checkin with the
diff buffer string.
(vc-checkin): New optional arg 'patch-string'.
Call backend function 'checkin-patch' when 'patch-string' is non-nil.
Call vc-start-logentry with 'patch-string'.
(vc-diff-patch-string): New function.
2022-08-28 22:38:51 +03:00
Stefan Kangas
b7e867b841 Make point-at-eol and point-at-bol obsolete
* lisp/subr.el (point-at-eol, point-at-bol): Make XEmacs compat
aliases obsolete in favor of `pos-bol'/'line-beginning-position' or
'pos-eol'/'line-end-position'.  Update callers.
Ref: https://lists.gnu.org/r/emacs-devel/2022-08/msg00853.html
2022-08-23 04:54:57 +02:00
Stefan Kangas
358ad0d30a Merge from origin/emacs-28
14833cd9df Improve wording when documenting other TRAMP syntaxes
628df15da5 ; * doc/misc/viper.texi (Rudimentary Changes): Avoid alias.
85de996bbb * lisp/vc/diff-mode.el: Don't mention XEmacs.
2022-08-10 06:31:02 +02:00
Stefan Kangas
85de996bbb * lisp/vc/diff-mode.el: Don't mention XEmacs. 2022-08-08 21:44:01 +02:00
YugaEgo
f21feaf00e Improve 'diff-whitespace-style' user option declaration
* lisp/vc/diff-mode.el (diff-whitespace-style):
Use ':require'.  Minor docstring fix.
(top level): Do not require 'whitespace.
(whitespace-style, whitespace-trailing-regexp):
Add defvars (rollback recent removal).
* etc/NEWS: Extend 'diff-whitespace-style' introduction.
(Bug#56679) (bug#56679).
2022-07-27 11:52:22 +02:00
YugaEgo
2c980815f5 Add new user option 'diff-whitespace-style'
* lisp/vc/diff-mode.el (diff-whitespace-style): New user option.
(diff-setup-whitespace): Use it (Bug#56679).
(top level): require 'whitespace.
(whitespace-style, whitespace-trailing-regexp): Remove defvars.
2022-07-24 11:06:57 +02:00
Stefan Kangas
52c91122ee Merge from origin/emacs-28
1c3d107cb5 Fix "C-u C-x =" for SPC
7e33618bbc ; * src/fns.c (Frequire): Fix a typo in the doc string.  (...
6908309827 Doc fixes: don't refer to some obsolete items
dc3cb749f3 Remove obsolete cust-print from elisp index
9ffbbddf8e * admin/make-tarball.txt: Minor clarifications.
f5421104e9 Fix external image conversion on MS-Windows
6f22631a63 * doc/emacs/buffers.texi (Indirect Buffers): Mention modif...

# Conflicts:
#	doc/emacs/buffers.texi
#	lisp/emacs-lisp/nadvice.el
#	lisp/image/image-converter.el
2022-07-02 09:33:51 +02:00
Stefan Kangas
6908309827 Doc fixes: don't refer to some obsolete items
* admin/notes/multi-tty:
* lisp/chistory.el (command-history):
* lisp/emacs-lisp/nadvice.el:
* lisp/vc/diff-mode.el: Doc fix; don't refer to obsolete variables and
functions.
2022-06-30 23:18:45 +02:00
Stefan Monnier
aee101af91 * lisp/vc/diff-mode.el (diff--font-lock-prettify): Fix diff-buffers case 2022-06-29 11:47:24 -04:00
Lars Ingebrigtsen
871f0f0a5d Make diff--font-lock-prettify do less if we don't have a left fringe
* lisp/vc/diff-mode.el (diff--font-lock-prettify): Don't remove
insert/deletions from the buffer if we don't have a left fringe
(bug#37019).
2022-05-20 03:38:27 +02:00
Matthias Meulien
4397755983 Display file mode information when diff font lock prettify enabled
* lisp/vc/diff-mode.el (diff--font-lock-prettify): Make regexp capture
file mode information.
2022-04-07 16:01:31 -04:00
Stefan Monnier
8e90216389 * lisp/vc/diff-mode.el (diff--font-lock-prettify): Recognize mode changes 2022-02-21 18:53:05 -05:00
Stefan Monnier
89f399324b * lisp/vc/diff-mode.el (diff--font-lock-prettify): bug#54034
Handle Git's output when deleting and creating empty files, as well as
when the diff is not shown because the file is considered as binary.
2022-02-21 17:22:38 -05:00
Stefan Monnier
910cdcf8c3 * lisp/vc/diff-mode.el (diff--font-lock-prettify): Fix mishaps
This reverts the last change so it also applies to non-git diffs again.
Instead, we're now more careful not to mis-recognize file headers as
addition/removal lines.
In addition to that, mark the file header such that it's
re-font-locked all at once, and to still recognize it after
`diff-reverse-direction`.
2022-02-19 13:45:04 -05:00
Matthias Meulien
b299c04201 Fix computation of outline heading level for non-git diff
* lisp/vc/diff-mode.el (diff-setup-buffer-type): Compute outline heading level
using diff-hunk-header-re (bug#51809).
(diff--font-lock-prettify): Disable prettify in non-git diff.
2022-02-16 21:19:45 +02:00
Stefan Monnier
d52c929e31 (with-demoted-errors): Warn on missing format arg
The `format` arg has been mandatory for a while, but the backward
compatibility code that handled the case of a missing `format` arg
made it hard to notice when using the old calling convention.

* lisp/subr.el (with-demoted-errors): Warn on missing `format` arg.

* lisp/emacs-lisp/smie.el (smie-indent--separator-outdent): Don't abuse
`with-demoted-errors`.
(smie-indent-line, smie-auto-fill):
* test/lisp/emacs-lisp/ert-tests.el (ert-test-with-demoted-errors):
* lisp/vc/vc-hooks.el (vc-refresh-state):
* lisp/vc/vc-annotate.el (vc-annotate-background-mode):
* lisp/vc/diff-mode.el (diff-syntax-fontify-hunk):
* lisp/textmodes/reftex-toc.el (reftex-re-enlarge):
* lisp/progmodes/sh-script.el (sh-smie-sh-rules):
* lisp/progmodes/octave.el (inferior-octave-startup):
* lisp/pcmpl-gnu.el (pcmpl-gnu-make-all-targets):
* lisp/org/org-refile.el (org-refile):
* lisp/org/org-capture.el (org-capture-store-last-position):
* lisp/nxml/nxml-mode.el (nxml-mode):
* lisp/notifications.el (notifications-notify):
* lisp/gnus/mm-view.el (mm-display-inline-fontify):
* lisp/finder.el (finder-unload-function):
* lisp/files.el (safe-local-variable-p, backup-buffer-copy
* lisp/autorevert.el (auto-revert-notify-handler):
Pass `format` arg to `with-demoted-errors`.
2022-02-04 19:39:53 -05:00
Lars Ingebrigtsen
8d4fffb643 Remove text mistakenly added to the diff--iterate-hunks doc string
* lisp/vc/diff-mode.el (diff--iterate-hunks): Remove text added by
mistake to the doc string.
2022-01-21 14:31:11 +01:00
Lars Ingebrigtsen
502dbd1f7c Make diff--iterate-hunks more resilient
* lisp/vc/diff-mode.el (diff--iterate-hunks): Ignore malformed
hunks instead of signalling errors (bug#53343).
2022-01-21 12:07:04 +01:00
Juri Linkov
97806bc7de Add diff-mode-read-only to enable shorter keys in diff-mode
To be able to use outline-minor-mode-cycle keys in diff-mode,
outline-minor-mode should be higher in minor-mode-map-alist,
and a new variable diff-mode-read-only should be set
when the diff-mode buffer is read-only.
https://lists.gnu.org/archive/html/emacs-devel/2022-01/msg00740.html

* lisp/vc/diff-mode.el: Add diff-mode-read-only to minor-mode-map-alist.
(diff-mode-read-only): New buffer-local variable.
(diff-mode): Set diff-mode-read-only to t when buffer-read-only is non-nil.
Update diff-mode-read-only in read-only-mode-hook.
Remove buffer-read-only from minor-mode-overriding-map-alist.
Remove view-mode-hook because now view-mode is higher than
diff-mode-read-only in minor-mode-map-alist.

* lisp/vc/vc-git.el (vc-git-stash-show):
* lisp/vc/vc.el (vc-diff-internal): Set buffer-read-only to t
before calling diff-mode that will set diff-mode-read-only.
2022-01-10 20:29:53 +02:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Tassilo Horn
7715fb3eff Revert "Revert "Fix fontification in diff--font-lock-prettify""
This reverts commit 3cadd72673.
2021-12-29 18:00:52 +01:00
Tassilo Horn
3cadd72673 Revert "Fix fontification in diff--font-lock-prettify"
This reverts commit 1da392d62d.
2021-12-29 18:00:30 +01:00
Matthias Meulien
1da392d62d Fix fontification in diff--font-lock-prettify
* lisp/vc/diff-mode.el (diff--font-lock-prettify): Fix
diff--font-lock-prettify on created or deleted files
(bug#52810).
2021-12-29 17:25:35 +01:00
Juri Linkov
71f237d668 * lisp/vc/diff-mode.el (diff-minor-mode-prefix): Fix typo from 44faf54659 2021-11-18 19:13:48 +02:00
Lars Ingebrigtsen
44faf54659 Revert VC-related prefix user options to previous values
* lisp/vc/smerge-mode.el (smerge-command-prefix):
* lisp/vc/pcvs.el (cvs-minor-mode-prefix):
* lisp/vc/diff-mode.el (diff-minor-mode-prefix): Revert to
previous values, as external packages rely on those values.
2021-11-18 12:11:35 +01:00
Lars Ingebrigtsen
2daffe3550 Adjust defvar-keymap' and define-keymap' to the new syntax
* lisp/vc/smerge-mode.el (smerge-basic-map):
* lisp/vc/pcvs.el (cvs-mode-map):
(cvs-minor-mode-prefix):
* lisp/vc/log-view.el (log-view-mode-map):
* lisp/vc/log-edit.el (log-edit-mode-map):
* lisp/vc/diff-mode.el (diff-mode-shared-map):
(diff-minor-mode-prefix):
* lisp/vc/cvs-status.el (cvs-status-mode-map):
* lisp/simple.el (special-mode-map):
* lisp/outline.el (outline--insert-open-button):
(outline--insert-close-button):
* lisp/net/shr.el (shr-map):
* lisp/net/eww.el (eww-link-keymap):
(eww-mode-map):
(eww-submit-map):
(eww-bookmark-mode-map):
(eww-history-mode-map):
(eww-buffers-mode-map):
* lisp/mh-e/mh-speed.el (:keymap):
* lisp/mh-e/mh-show.el (:keymap):
* lisp/mh-e/mh-search.el (:keymap):
* lisp/mh-e/mh-letter.el (:keymap):
* lisp/mh-e/mh-folder.el (:keymap):
* lisp/international/emoji.el (emoji-list-mode-map):
* lisp/gnus/spam.el (:keymap):
* lisp/gnus/mml.el (mml-mode-map):
* lisp/gnus/message.el (message-mode-map):
* lisp/gnus/gnus-undo.el (gnus-undo-mode-map):
* lisp/gnus/gnus-topic.el (gnus-topic-mode-map):
* lisp/gnus/gnus-sum.el (:keymap):
* lisp/gnus/gnus-srvr.el (gnus-server-mode-map):
(gnus-browse-mode-map):
* lisp/gnus/gnus-salt.el (gnus-pick-mode-map):
(gnus-tree-mode-map):
* lisp/gnus/gnus-msg.el (:prefix):
* lisp/gnus/gnus-ml.el (gnus-mailing-list-mode-map):
* lisp/gnus/gnus-kill.el (gnus-kill-file-mode-map):
* lisp/gnus/gnus-html.el (gnus-html-displayed-image-map):
* lisp/gnus/gnus-group.el (:keymap):
* lisp/gnus/gnus-eform.el (gnus-edit-form-mode-map):
* lisp/gnus/gnus-draft.el (gnus-draft-mode-map):
* lisp/gnus/gnus-dired.el (gnus-dired-mode-map):
* lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-mode-map):
* lisp/gnus/gnus-art.el (:keymap):
(gnus-article-edit-mode-map):
* lisp/gnus/gnus-agent.el (gnus-agent-group-mode-map):
(gnus-agent-summary-mode-map):
(gnus-agent-server-mode-map):
(gnus-category-mode-map): Adjust `defvar-keymap' and
`define-keymap' to the new syntax.
2021-11-16 08:26:24 +01:00
Juri Linkov
565514fe96 * lisp/vc/diff-mode.el (diff-setup-buffer-type): Move to diff-setup-whitespace
* lisp/vc/vc.el: Add declare-function for diff-setup-buffer-type (bug#51016).
2021-11-09 10:18:24 +02:00
Matthias Meulien
358b8d0361 Fix local variables overwritten when diff-mode is set
* lisp/vc/diff-mode.el (diff-mode):
(diff-setup-buffer-type): Defun to initialize `diff-buffer-type'

* lisp/vc/vc.el (vc-diff-finish): Set `diff-buffer-type' after content
inserted
(vc-diff-internal): Restore `diff-mode' being set before local
variables (bug#51016).
2021-11-09 04:46:53 +01:00
Matthias Meulien
f0768d3145 Fix 'diff-font-lock-prettify' breaking display of outline headers
* lisp/vc/diff-mode.el (diff-outline-level): Make hunk headers be
at level 2.
(diff-mode): Use prettified line as outline header.
(diff--outline-level): New function (bug#51016).

* lisp/vc/vc.el (vc-diff-internal): Fix diff mode being set before
content inserted (bug#51016).
2021-11-05 03:50:01 +01:00
Lars Ingebrigtsen
fbf7dd3cce Fix diff-mode-shared-map
* lisp/vc/diff-mode.el (diff-mode-shared-map): Fix syntax error in
`defvar-keymap' change.
2021-10-19 04:36:05 +02:00
Lars Ingebrigtsen
25e624e585 Fix possible build issue in pcvs.el and diff-mode.el
* lisp/vc/pcvs.el (easy-mmode):
* lisp/vc/diff-mode.el (easy-mmode): Require.
2021-10-18 09:22:22 +02:00
Lars Ingebrigtsen
9efa67f764 Convert diff-mode.el from easy-mmode-defmap to define-keymap
* lisp/vc/diff-mode.el (diff-mode-shared-map, diff-mode-map)
(diff-minor-mode-map): Convert from easy-mmode-defmap to
defvar-keymap.
2021-10-18 00:49:56 +02:00
Konstantin Kharlamov
150fc9c845 Do not count git markers as "deleted lines"
* lisp/vc/diff-mode.el (diff-fixup-modifs): Skip "end of patch"
markers that `git-format-patch` leaves around (bug#50761).
2021-09-23 23:25:41 +02:00
Stefan Kangas
25ebb9374b ; More minor docfixes found by checkdoc 2021-09-14 07:57:14 +02:00
Lars Ingebrigtsen
3c053ef142 Filter out -L foo labels in diff-hunk-file-names
* lisp/vc/diff-mode.el (diff-hunk-file-names): Filter out "-L foo"
labels (bug#10160).
2021-08-14 15:50:55 +02:00
Lars Ingebrigtsen
e30c7f314b Adjust previous diff-changed-unspecified change
* lisp/vc/diff-mode.el (diff-changed-unspecified): Adjust the
definition to Emacs 28 (bug#26969).
2021-08-13 15:37:21 +02:00
Lars Ingebrigtsen
4d51c2c472 Add new face diff-changed-unspecified
* lisp/vc/diff-mode.el (diff-changed-unspecified): New face.
(diff-font-lock-keywords): Use it (bug#26969).
2021-08-13 15:35:49 +02:00
Jim Porter
ed30a7290c Ignore file-missing errors during diff-refined font-locking
* lisp/vc/diff-mode.el (diff--font-lock-refined): Ignore file-missing
errors (bug#49197).
2021-06-24 18:07:25 +02:00