Commit graph

182 commits

Author SHA1 Message Date
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
Juri Linkov
856e0ec2f8 * lisp/vc/diff-mode.el (diff-hunk-text): Test-driven fix for newlines.
* lisp/vc/diff-mode.el (diff-hunk-text): Fix handling of newlines
to cover all test cases according to new test.

* test/lisp/vc/diff-mode-tests.el (diff-mode-test-hunk-text-no-newline):
New test to cover cases with no newline at end of file.
2021-05-27 01:19:36 +03:00
Juri Linkov
9be9d1f94e * lisp/vc/diff-mode.el (diff-hunk-text): Handle better "\ No newline at end". 2021-05-20 21:23:01 +03:00
Stefan Kangas
8b07994e20 Convert many more links to use HTTPS 2021-03-24 10:20:18 +01:00
Stefan Monnier
0d827c7f52 * lisp/emacs-lisp/pcase.el: Fix bug#46786
Revert commit a218c98615, but in order
to avoid the spurious warnings that this commit tried to squash,
keep track of the vars used during the match so as to add
corresponding annotations to explicitly silence the spurious warnings.

To do this, we change the VARS used in `pcase-u` (and throughout
the pcase code): they used to hold elements of the form (NAME . VAL)
and now they hold elements of the form (NAME VAL . USED).

(pcase--expand): Bind all vars instead of only those found via fgrep.
(pcase-codegen): Silence "unused var" warnings for those vars that have
already been referenced during the match itself.
(pcase--funcall, pcase--eval): Record the vars that are used.
(pcase--u1): Record the vars that are used via non-linear patterns.

* lisp/textmodes/mhtml-mode.el (mhtml-forward):
* lisp/vc/diff-mode.el (diff-goto-source): Silence newly
discovered warnings.

* test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-bug46786): New test.
2021-03-01 15:35:51 -05:00
Stefan Monnier
99340ad17a lisp/vc/*.el: Use lexical-bindings in all the files
Also remove some redundant `:group` arguments.

* lisp/vc/vc.el (vc-ignore): Autoload.

* lisp/vc/pcvs-util.el (cvs-every, cvs-union, cvs-map): Delete functions.
* lisp/vc/cvs-status.el: Require `cl-lib` at runtime.
(cvs-tree-tags-insert): Use `cl-mapcar` and `cl-every` instead.
* lisp/vc/pcvs.el: Require `cl-lib` at runtime.
(cvs-do-removal): Use `cl-every` instead.

* lisp/vc/ediff-init.el: Require `ediff-util` (for `ediff-cleanup-mess`
and `ediff-default-suspend-function`).

* lisp/vc/pcvs-info.el (cvs-fileinfo<): Remove unused vars `subtypea`
and `subtypeb`.

* lisp/vc/vc-git.el:
* lisp/vc/vc-bzr.el: Require `vc-dispatcher` at runtime for
`vc-do-async-command`.
2021-02-26 16:51:15 -05:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00
Stefan Kangas
5ef30fbf11 Prefer setq-local in vc/*.el
* lisp/vc/add-log.el (find-change-log, change-log-mode):
* lisp/vc/cvs-status.el (cvs-status-mode):
* lisp/vc/diff-mode.el (diff-restrict-view, diff-find-file-name):
(diff-mode, diff-setup-whitespace, diff-apply-hunk):
* lisp/vc/diff.el (diff-no-select):
* lisp/vc/ediff-util.el (ediff-setup):
* lisp/vc/log-edit.el (log-edit, log-edit-mode):
* lisp/vc/log-view.el (log-view-mode):
* lisp/vc/pcvs.el (cvs-temp-buffer, cvs-make-cvs-buffer):
(cvs-update-filter, cvs-mode, cvs-mode-commit)
(cvs-mode-edit-log, cvs-vc-command-advice):
* lisp/vc/smerge-mode.el (smerge-match-conflict):
(smerge-ediff, smerge-mode):
* lisp/vc/vc-annotate.el (vc-annotate-mode):
(vc-annotate, vc-annotate-display):
* lisp/vc/vc-bzr.el (vc-bzr-log-view-mode):
* lisp/vc/vc-dir.el (vc-dir-mode):
* lisp/vc/vc-dispatcher.el (vc-setup-buffer):
(vc-compilation-mode, vc-start-logentry):
* lisp/vc/vc-git.el (vc-git-log-view-mode):
* lisp/vc/vc-hg.el (vc-hg-log-view-mode):
* lisp/vc/vc-hooks.el (vc-refresh-state):
* lisp/vc/vc-mtn.el (vc-mtn-log-view-mode):
* lisp/vc/vc-svn.el (vc-svn-log-view-mode):
* lisp/vc/vc.el (vc-register, vc-diff-internal):
(vc-find-revision-save, vc-find-revision-no-save):
(vc-log-internal-common, vc-region-history): Prefer setq-local.
2020-12-05 08:58:12 +01:00
Michael Albinus
67a8bdb90c Use null-device where appropriate
* lisp/filesets.el (filesets-select-command):
* lisp/shell.el (shell-mode):
* lisp/term.el (term-exec-1):
* lisp/wdired.el (wdired-do-symlink-changes):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-create):
* lisp/eshell/esh-io.el (eshell-set-output-handle):
* lisp/gnus/gnus-fun.el (gnus-grab-cam-x-face):
* lisp/gnus/mml2015.el (mml2015-epg-key-image):
* lisp/gnus/smime.el (smime-noverify-region):
* lisp/org/ob-picolisp.el (org-babel-execute:picolisp):
* lisp/org/ob-screen.el (org-babel-prep-session:screen)
(org-babel-prep-session:screen):
* lisp/play/fortune.el (fortune-quiet-strfile-options):
* lisp/progmodes/cperl-mode.el (cperl-pod2man-build-command):
* lisp/progmodes/sh-script.el (sh-tmp-file):
* lisp/vc/diff-mode.el (diff-add-log-current-defuns)
(diff--font-lock-prettify):
* lisp/vc/ediff-mult.el (ediff-patch-file-form-meta):
* lisp/vc/ediff-ptch.el (ediff-map-patch-buffer)
(ediff-fixup-patch-map, ediff-dispatch-file-patching-job):
* lisp/vc/vc.el (vc-diff-internal): Use null-device or 	(null-device),
respectively.  (Bug#3736)
2020-11-25 22:13:33 +01:00
Protesilaos Stavrou
de7d9e1f88 Clarify that 'diff-error' is part of Emacs 28.1
* lisp/vc/diff-mode.el (diff-error): Add :version tag (bug#44727).
2020-11-18 21:47:43 +00:00
Dima Kogan
0836335cdf Add a new command to regenerate a hunk in diff-mode
* lisp/vc/diff-mode.el (diff-refresh-hunk): New function (bug#44312).
(diff-mode-map): Bind C-c C-l.
2020-10-30 14:04:06 +01:00
Lars Ingebrigtsen
0a3d584ce4 Avoid infloop in which-function-mode when a vc file has changed
* lisp/vc/diff-mode.el (diff-find-source-location): Avoid warnings
when called from which-function-mode and the file has changed
(bug#42818).
2020-10-17 10:29:15 +02:00
Lars Ingebrigtsen
8b4dd261cb diff-update-on-the-fly doc string clarification
* lisp/vc/diff-mode.el (diff-update-on-the-fly): Mention what the
nil value does (bug#43297).
2020-10-16 08:46:07 +02:00
Lars Ingebrigtsen
54c2a8df3b Make diff--refine-hunk bug out less on broken patches
* lisp/vc/diff-mode.el (diff--refine-hunk): Don't bug out on
broken patches where we can't find the middle.
2020-09-13 17:25:08 +02:00
Lars Ingebrigtsen
9ca83cdd79 Revert "Use format-prompt in read-file-name calls that have a default"
This reverts commit de4f347901.

read-file-name already displays a long path when given a default
(like INITIAL in many other prompting functions), so using
format-prompt here is superfluous.
2020-09-13 14:58:24 +02:00
Glenn Morris
5e7733694e Mark some diff tests as failing in nonascii directories
* test/lisp/vc/diff-mode-tests.el (diff-mode-test-font-lock)
(diff-mode-test-font-lock-syntax-one-line):
Expect failure in non-ascii directories.

; * lisp/vc/diff-mode.el (diff-hunk-file-names): Comment.
2020-09-12 19:47:29 -07:00
Lars Ingebrigtsen
de4f347901 Use format-prompt in read-file-name calls that have a default
* lisp/xwidget.el (xwidget-webkit-save-as-file):
* lisp/vc/vc.el (vc-backend-for-registration, vc-delete-file)
(vc-rename-file):
* lisp/vc/ediff-ptch.el (ediff-prompt-for-patch-file):
* lisp/vc/diff-mode.el (diff-tell-file-name):
* lisp/progmodes/etags.el (visit-tags-table)
(visit-tags-table-buffer):
* lisp/misearch.el (multi-isearch-read-files):
* lisp/mail/rmailmm.el (rmail-mime-save):
* lisp/help-fns.el (doc-file-to-man, doc-file-to-info):
* lisp/gnus/gnus-bookmark.el (gnus-bookmark-load):
* lisp/files.el (write-file, basic-save-buffer):
* lisp/dired.el (dired-read-dir-and-switches):
* lisp/bookmark.el (bookmark-save, bookmark-load):
* lisp/abbrev.el (write-abbrev-file, abbrev-edit-save-to-file):
Use format-prompt in read-file-name calls that have a default.
2020-09-07 22:10:06 +02:00
Lars Ingebrigtsen
4a8d3d81cf Highlight error messages from diff in diff-mode
* lisp/vc/diff-mode.el (diff-error): New face (bug#2739).
(diff-font-lock-keywords): Use it to highlight lines like "diff: "
which are error messages from diff (for instance, when a file
doesn't exist).
2020-08-21 15:58:32 +02:00
Lars Ingebrigtsen
bd0523901b Don't message the hunk status when just going to it
* lisp/vc/diff-mode.el (diff-goto-source): Don't output a status
about the hunk just when jumping to it (bug#38370).  This would
output "Hunk already applied" when browsing diffs.
2020-08-20 16:52:57 +02:00
Gregory Heytings
f3d93eb401 Fix visual fringe glitch in diff-mode
* lisp/vc/diff-mode.el (diff--font-lock-prettify): Fix problems
with visual gaps in the fringes when changing font size (bug#42300).

Copyright-paperwork-exempt: yes
2020-08-14 17:34:07 +02:00