unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay
@ 2023-02-12  5:32 Ramesh Nedunchezian
       [not found] ` <handler.61449.B.167618026110384.ack@debbugs.gnu.org>
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Ramesh Nedunchezian @ 2023-02-12  5:32 UTC (permalink / raw)
  To: 61449, ", dgutov"


[-- Attachment #1.1: Type: text/plain, Size: 4226 bytes --]

Would you mind adding a cookie to the overlay in
`diff-hl-dired-highlight-items`.

    (overlay-put o 'diff-hl-dired-cookie type)

If this cookie is available, I can use it in the following ways.

1. Mark the files based on vc state.  See command
   `diff-hl-dired-mark-vc-states` and the associated screenshot `M-x
   diff-hl-dired-mark-vc-states.png`.

2. Fontify the file names based on vc state.  See command
   `diff-hl-dired-fontify` and the associated screenshot `M-x
   diff-hl-dired-fontify.png`.

   
In a sense, (1) is a GOOD---this is subjective, ofcourse---one other
way of fontifying a dired lines on vc state.

- diff-hl-dired-mode :: Put the vc state in indicator in fringe
- diff-hl-margin-mode ::  Put the vc state in margin
- diff-hl-inline-mode(?) :: Put the vc state right on the file name or
  the dired line.  


I only need the cookie, and NOT the commands that I have attached.
Bonus points if you introduce some variation of my custom command in
the library.

----------------

Backstory: Yesterday, I was cleaning up a repo which I had been
working on-and-off for the last few years.  Even though it was version
controlled, there were lots of artifacts which were never checked in.
I was apprehensive that could be some interesting titbits in the
"unknown" file.  And there were quite a good number of "unknown" files
.... and I found `M-x vc-dired` too wordy, and distracting.

----------------

Remarks, and possible areas of improvement:

1. `diff-hl-dired-mode` kicks of an async process, and I wanted some
   visual indication that the async process has finished, and I am
   seeing ALL OF the unknown files.  I would have appreciated an echo
   area message, or a mode line indicator that the process has
   finished.

2. `C-x v d` recursively lists all "unregistered" files, but
   `diff-hl-dired-mode` lists only the entries in current directory.

    I would have appreciated an option to do a recursive listing of
   files ....

----------------

(require 'dash)
(require 'diff-hl-dired)

(add-hook 'dired-mode-hook
          'diff-hl-dired-mode)

(add-hook 'dired-mode-hook
          'dired-hide-details-mode)

(custom-set-faces
 '(diff-hl-dired-change ((t (:foreground "orange"))))
 '(diff-hl-dired-delete ((t (:foreground "red"))))
 '(diff-hl-dired-ignored ((t (:inherit dired-ignored :foreground "grey50"))))
 '(diff-hl-dired-insert ((t (:foreground "green"))))
 '(diff-hl-dired-unknown ((t (:inherit dired-ignored :foreground "grey75")))))

(defvar diff-hl-dired-types
  (->> (my-get-faces-matching-regexp "^diff-hl-dired-")
       (--map (->> it
                   symbol-name
                   (replace-regexp-in-string "^diff-hl-dired-" "")
                   intern))
       (cons nil)))

(defun diff-hl-dired-mark-vc-states (types)
  (interactive
   (->> (completing-read-multiple "VC State: "
                                  diff-hl-dired-types
                                  nil t)
        (-map #'intern)
        list))
  (when types
    (dired-mark-if
     (memq
      (when-let* ((diff-hl-overlay
                   (->> (overlays-in
                         (line-beginning-position)
                         (line-end-position))
                        (--filter (overlay-get it 'diff-hl))
                        car)))
        (overlay-get diff-hl-overlay 'diff-hl-dired-cookie))
      types)
     (format "files in vc-states `%s'"
             (string-join (mapcar #'symbol-name types) ",")))))

(defun dired-walk (f)
  (let ((beg (point-min))
        (end (point-max)))
    (save-excursion
      (goto-char beg)
      (while (< (point) end)
        (funcall f)
        (forward-line 1)))))

(defun diff-hl-dired-fontify ()
  (interactive)
  (dired-walk
   (lambda ()
     (when-let* ((diff-hl-overlay
                  (->> (overlays-in
                        (line-beginning-position)
                        (line-end-position))
                       (--filter (overlay-get it 'diff-hl))
                       car))
                 (cookie (overlay-get diff-hl-overlay 'diff-hl-dired-cookie)))
       (overlay-put (make-overlay (line-beginning-position) (line-end-position))
                    'face (diff-hl-dired-face-from-type cookie 'ignored))))))




[-- Attachment #1.2: Type: text/html, Size: 4534 bytes --]

[-- Attachment #2: M-x diff-hl-dired-mark-vc-states.png --]
[-- Type: image/png, Size: 31783 bytes --]

[-- Attachment #3: M-x diff-hl-dired-fontify.png --]
[-- Type: image/png, Size: 31076 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-02-18 23:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-12  5:32 bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay Ramesh Nedunchezian
     [not found] ` <handler.61449.B.167618026110384.ack@debbugs.gnu.org>
2023-02-12  5:41   ` bug#61449: Acknowledgement (30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay) Ramesh Nedunchezian
2023-02-12  6:34 ` bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay Ramesh Nedunchezian
2023-02-12 13:12 ` Dmitry Gutov
2023-02-13 11:32   ` Ramesh Nedunchezian
2023-02-12 13:12 ` Dmitry Gutov
2023-02-13 11:19   ` Ramesh Nedunchezian
2023-02-18 23:25     ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).