update packages

This commit is contained in:
2025-11-25 19:52:03 +01:00
parent 14ba373378
commit dbbae92267
280 changed files with 13451 additions and 11207 deletions

View File

@@ -22,9 +22,9 @@
;;; Commentary:
;; `diff-hl-show-hunk' shows a popup with the modification hunk at point.
;; `diff-hl-show-hunk-function' points to the backend used to show the
;; hunk. Its default value is `diff-hl-show-hunk-inline-popup', that
;; shows diffs inline using overlay. There is another built-in backend:
;; `diff-hl-show-hunk-function' points to the backend used to show the hunk.
;; Its default value is `diff-hl-show-hunk-inline', that shows diffs inline
;; using overlay. There is another built-in backend:
;; `diff-hl-show-hunk-posframe' (based on posframe).
;;
;; `diff-hl-show-hunk-mouse-mode' adds interaction on clicking in the
@@ -36,9 +36,31 @@
;;; Code:
(require 'diff-hl-inline-popup)
(require 'diff-hl)
(defgroup diff-hl-show-hunk nil
"Show vc diffs in a posframe or popup."
:group 'diff-hl)
(defcustom diff-hl-show-hunk-ignorable-commands
'(ignore
diff-hl-show-hunk
handle-switch-frame
diff-hl-show-hunk--click)
"Commands that will keep the hunk shown.
Any command not on this list will cause the hunk to be hidden."
:type '(repeat function)
:group 'diff-hl-show-hunk)
(defcustom diff-hl-show-hunk-function 'diff-hl-show-hunk-inline
"The function used to render the hunk.
The function receives as first parameter a buffer with the
contents of the hunk, and as second parameter the line number
corresponding to the clicked line in the original buffer."
:type '(choice
(const :tag "Show inline" diff-hl-show-hunk-inline)
(const :tag "Show using posframe" diff-hl-show-hunk-posframe)))
(defvar diff-hl-show-hunk-mouse-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<left-margin> <mouse-1>") 'diff-hl-show-hunk--click)
@@ -66,33 +88,9 @@
(defvar diff-hl-show-hunk--original-overlay nil
"Copy of the diff-hl hunk overlay.")
(defgroup diff-hl-show-hunk nil
"Show vc diffs in a posframe or popup."
:group 'diff-hl)
(defconst diff-hl-show-hunk-boundary "^@@.*@@")
(defconst diff-hl-show-hunk--no-lines-removed-message (list "<<no lines removed>>"))
(defcustom diff-hl-show-hunk-inline-popup-hide-hunk nil
"If t, inline-popup is shown over the hunk, hiding it."
:type 'boolean)
(defcustom diff-hl-show-hunk-inline-popup-smart-lines t
"If t, inline-popup tries to show only the deleted lines of the
hunk. The added lines are shown when scrolling the popup. If
the hunk consist only on added lines, then
`diff-hl-show-hunk--no-lines-removed-message' it is shown."
:type 'boolean)
(defcustom diff-hl-show-hunk-function 'diff-hl-show-hunk-inline-popup
"The function used to render the hunk.
The function receives as first parameter a buffer with the
contents of the hunk, and as second parameter the line number
corresponding to the clicked line in the original buffer."
:type '(choice
(const :tag "Show inline" diff-hl-show-hunk-inline-popup)
(const :tag "Show using posframe" diff-hl-show-hunk-posframe)))
(defvar diff-hl-show-hunk--hide-function nil
"Function to call to close the shown hunk.")
@@ -123,7 +121,7 @@ corresponding to the clicked line in the original buffer."
(defun diff-hl-show-hunk-ignorable-command-p (command)
"Decide if COMMAND is a command allowed while showing the current hunk."
(member command '(ignore diff-hl-show-hunk handle-switch-frame diff-hl-show-hunk--click)))
(member command diff-hl-show-hunk-ignorable-commands))
(defun diff-hl-show-hunk--compute-diffs ()
"Compute diffs using functions of diff-hl.
@@ -136,7 +134,10 @@ buffer."
(line (line-number-at-pos))
(dest-buffer diff-hl-show-hunk-diff-buffer-name))
(with-current-buffer buffer
(diff-hl-diff-buffer-with-reference (buffer-file-name buffer) dest-buffer)
(if (buffer-modified-p)
(diff-hl-diff-buffer-with-reference buffer-file-name dest-buffer)
(diff-hl-changes-buffer buffer-file-name (vc-backend buffer-file-name)
nil dest-buffer))
(switch-to-buffer dest-buffer)
(diff-hl-diff-skip-to line)
(setq vc-sentinel-movepoint (point)))
@@ -226,68 +227,6 @@ Returns a list with the buffer and the line number of the clicked line."
(define-key map (kbd "S") #'diff-hl-show-hunk-stage-hunk)
map))
(defvar diff-hl-show-hunk--hide-function)
;;;###autoload
(defun diff-hl-show-hunk-inline-popup (buffer &optional _ignored-line)
"Implementation to show the hunk in a inline popup.
BUFFER is a buffer with the hunk."
(diff-hl-inline-popup-hide)
(setq diff-hl-show-hunk--hide-function #'diff-hl-inline-popup-hide)
(let* ((lines (split-string (with-current-buffer buffer (buffer-string)) "[\n\r]+" ))
(smart-lines diff-hl-show-hunk-inline-popup-smart-lines)
(original-lines-number (cl-count-if (lambda (s) (string-prefix-p "-" s)) lines))
(lines (if (string= (car (last lines)) "" ) (butlast lines) lines))
(lines (if (and (eq original-lines-number 0) smart-lines)
diff-hl-show-hunk--no-lines-removed-message
lines))
(overlay diff-hl-show-hunk--original-overlay)
(type (overlay-get overlay 'diff-hl-hunk-type))
(point (if (eq type 'delete) (overlay-start overlay) (overlay-end overlay)))
(propertize-line (lambda (l)
(propertize l 'face
(cond ((string-prefix-p "+" l)
'diff-added)
((string-prefix-p "-" l)
'diff-removed)))))
(propertized-lines (mapcar propertize-line lines)))
(save-excursion
;; Save point in case the hunk is hidden, so next/previous works as expected
;; If the hunk is delete type, then don't hide the hunk
;; (because the hunk is located in a non deleted line)
(when (and diff-hl-show-hunk-inline-popup-hide-hunk
(not (eq type 'delete)))
(let* ((invisible-overlay (make-overlay (overlay-start overlay)
(overlay-end overlay))))
;; Make new overlay, since the diff-hl overlay can be changed by diff-hl-flydiff
(overlay-put invisible-overlay 'invisible t)
;; Change default hide popup function, to make the overlay visible
(setq diff-hl-show-hunk--hide-function
(lambda ()
(overlay-put invisible-overlay 'invisible nil)
(delete-overlay invisible-overlay)
(diff-hl-inline-popup-hide)))))
(diff-hl-show-hunk--goto-hunk-overlay overlay)
(let ((height
(when smart-lines
(when (not (eq 0 original-lines-number))
original-lines-number)))
(footer "(q)Quit (p)Previous (n)Next (r)Revert (c)Copy original"))
(unless diff-hl-show-staged-changes
(setq footer (concat footer " (S)Stage")))
(diff-hl-inline-popup-show
propertized-lines
(if (and (boundp 'diff-hl-reference-revision) diff-hl-reference-revision)
(concat "Diff with " diff-hl-reference-revision)
"Diff with HEAD")
footer
diff-hl-show-hunk-map
#'diff-hl-show-hunk-hide
point
height))
)))
(defun diff-hl-show-hunk-copy-original-text ()
"Extracts all the lines from BUFFER starting with '-' to the kill ring."
(interactive)