all messages for Emacs-related lists mirrored at yhetil.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

* bug#61449: Acknowledgement (30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay)
       [not found] ` <handler.61449.B.167618026110384.ack@debbugs.gnu.org>
@ 2023-02-12  5:41   ` Ramesh Nedunchezian
  0 siblings, 0 replies; 8+ messages in thread
From: Ramesh Nedunchezian @ 2023-02-12  5:41 UTC (permalink / raw)
  To: 61449; +Cc: dgutov

Courtesy copy to the author of `diff-hl`







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

* bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay
  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  6:34 ` Ramesh Nedunchezian
  2023-02-12 13:12 ` Dmitry Gutov
  2023-02-12 13:12 ` Dmitry Gutov
  3 siblings, 0 replies; 8+ messages in thread
From: Ramesh Nedunchezian @ 2023-02-12  6:34 UTC (permalink / raw)
  To: 61449

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

On 12/02/23 11:02, Ramesh Nedunchezian wrote:
> (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)))
>
I forgot this fragment

    (defun my-get-faces-matching-regexp (regexp)
      (cl-loop for sym being the symbols
               when (facep sym)
               when (string-match-p regexp (format "%s" sym))
               collect sym))

or you can do this

    (setq diff-hl-dired-types
          '(nil insert delete unknown ignored change))




[-- Attachment #2: Type: text/html, Size: 1117 bytes --]

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

* bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay
  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  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
  3 siblings, 1 reply; 8+ messages in thread
From: Dmitry Gutov @ 2023-02-12 13:12 UTC (permalink / raw)
  To: Ramesh Nedunchezian, 61449

On 12/02/2023 07:32, Ramesh Nedunchezian wrote:
> 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.

I was worried it could be too distracting, to show that every time one 
enters a directory. Perhaps a user option could be added.

> 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 ....

I'm pretty sure the unregistered files are mentioned recursively. But 
the indicator is put on the containing directory. How else would we do that?





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

* bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay
  2023-02-12  5:32 bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay Ramesh Nedunchezian
                   ` (2 preceding siblings ...)
  2023-02-12 13:12 ` Dmitry Gutov
@ 2023-02-12 13:12 ` Dmitry Gutov
  2023-02-13 11:19   ` Ramesh Nedunchezian
  3 siblings, 1 reply; 8+ messages in thread
From: Dmitry Gutov @ 2023-02-12 13:12 UTC (permalink / raw)
  To: Ramesh Nedunchezian, 61449

Hi!

On 12/02/2023 07:32, Ramesh Nedunchezian wrote:
>        (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))

Why do you need a cookie here?

IIUC all such overlays (with 'diff-hl' property) inside Dired buffers 
are relevant.





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

* bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay
  2023-02-12 13:12 ` Dmitry Gutov
@ 2023-02-13 11:19   ` Ramesh Nedunchezian
  2023-02-18 23:25     ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Ramesh Nedunchezian @ 2023-02-13 11:19 UTC (permalink / raw)
  To: Dmitry Gutov, 61449

[-- Attachment #1: Type: text/plain, Size: 2121 bytes --]


On 12/02/23 18:42, Dmitry Gutov wrote:
> Hi!
>
> On 12/02/2023 07:32, Ramesh Nedunchezian wrote:
>>        (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))
>
> Why do you need a cookie here?
>
> IIUC all such overlays (with 'diff-hl' property) inside Dired buffers are relevant.


I have attached screenshots on what I could achieve with the cookie.
I have also provided recipes for how the cookie could be used.

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

The information I am looking for is vc state, and it is buried too
deep inside.

Let me elaborate ... if I eval the form you have quoted above, I would
get

    (setq x '(modification-hooks
              (diff-hl-overlay-modified)
              diff-hl-dired-cookie change before-string
              #(" " 0 1
                (display
                 ((left-fringe exclamation-mark diff-hl-dired-change))))
              diff-hl t))


Note that the `diff-hl-dired-cookie` is added by me, and
`diff-hl-dired` adds the follwing properties
          

- `diff-hl-dired-cookie` :: This is added by me, and contains the vc
  state.
- `diff-hl` :: This is added by `diff-hl-dired`, and `t` isn't much
  useful for the task I have hand.
- `before-string` :: This is added by `diff-hl-dired`, and the vc
  state is avaiable as a face property.

  If I have to get to that property, this is the kind of manoeuvre I
  need to do

    (->> x
         (memq 'before-string)
         cadr
         (get-text-property 0 'display)
         car
         (-filter 'facep)
         car)

If you add a cookie, I can do whatever with it. 

Mind you ... I am not saying the relevant information is /not/ there; 
I am only saying that it is buried too deep, and not readily accessible.

[-- Attachment #2: Type: text/html, Size: 3247 bytes --]

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

* bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay
  2023-02-12 13:12 ` Dmitry Gutov
@ 2023-02-13 11:32   ` Ramesh Nedunchezian
  0 siblings, 0 replies; 8+ messages in thread
From: Ramesh Nedunchezian @ 2023-02-13 11:32 UTC (permalink / raw)
  To: Dmitry Gutov, 61449


On 12/02/23 18:42, Dmitry Gutov wrote:
> On 12/02/2023 07:32, Ramesh Nedunchezian wrote:
>> 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.
>
> I was worried it could be too distracting, to show that every time one enters a directory. Perhaps a user option could be added.


>
>> 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 ....
>
> I'm pretty sure the unregistered files are mentioned recursively. But the indicator is put on the containing directory. How else would we do that?


`vc-dired` does what I want, but the annotation added by `vc-dired` `unregistered` etc were too distracting. 

If you look at the screenshots  I shared, you will see that the file names are fontified based on their vc state.

There is also a command to mark files by their state, and I can bulk delete, move or commit the files.

So, task I had is already accomplished with recipes I shared ... and I felt that enhancing `diff-hl-dired` could be generally useful.







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

* bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay
  2023-02-13 11:19   ` Ramesh Nedunchezian
@ 2023-02-18 23:25     ` Dmitry Gutov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2023-02-18 23:25 UTC (permalink / raw)
  To: Ramesh Nedunchezian, 61449

Hi again!

On 13/02/2023 13:19, Ramesh Nedunchezian wrote:
> - `diff-hl-dired-cookie` :: This is added by me, and contains the vc
>    state.
> - `diff-hl` :: This is added by `diff-hl-dired`, and `t` isn't much
>    useful for the task I have hand.
> - `before-string` :: This is added by `diff-hl-dired`, and the vc
>    state is avaiable as a face property.
> 
>    If I have to get to that property, this is the kind of manoeuvre I
>    need to do
> 
>      (->> x
>           (memq 'before-string)
>           cadr
>           (get-text-property 0 'display)
>           car
>           (-filter 'facep)
>           car)
> 
> If you add a cookie, I can do whatever with it.
> 
> Mind you ... I am not saying the relevant information is /not/ there;
> I am only saying that it is buried too deep, and not readily accessible.

Thank you for the extra clarification.

I've added a new overlay property 'diff-hl-dired-type' in 
https://github.com/dgutov/diff-hl/commit/d20f16bf5eadd66e775f215e800f25caddae8cb5.

It the same as you asked, I think, except with a different name.

Due to the version bump, it should be out soon in diff-hl 1.9.2.





^ 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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.