GNU bug report logs - #61449
30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay

Previous Next

Package: emacs;

Reported by: Ramesh Nedunchezian <rameshnedunchezian <at> outlook.com>

Date: Sun, 12 Feb 2023 05:38:02 UTC

Severity: normal

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Ramesh Nedunchezian <rameshnedunchezian <at> outlook.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>, 61449 <at> debbugs.gnu.org
Subject: bug#61449: 30.0.50; diff-hl-dired: Consider adding a cookie to diff-hl-dired overlay
Date: Mon, 13 Feb 2023 16:49:35 +0530
[Message part 1 (text/plain, inline)]
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.
[Message part 2 (text/html, inline)]

This bug report was last modified 2 years and 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.