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.