emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sv: Sv: Partial wdired (edit just filename at the point)


From: arthur miller
Subject: Sv: Sv: Partial wdired (edit just filename at the point)
Date: Sat, 20 Mar 2021 11:23:44 +0000

Ok. Thanks for the guidance, I really wasn't that introduced into wdired, so
that last explanation really helped.

So here is a suggestion to one strategy:

When self-insert-command is called, check if point is in column bounds for
permissions. If that is case we check if the line was already processed. If line
has not been processed we call our before change function which will trigger
processing of the line so that keymap property is properly sett. Finally we put
back the event and let Emacs do it's thing: it will check again on same event
but this time there will be keymap property and wdired-set-bit will be triggered.

(defun wdired--self-insert ()
  (interactive)
  (if (wdired--point-at-perms-p)
    (when (not (get-text-property (line-beginning-position) 'front-sticky))
      (wdired--before-change-fn (line-beginning-position) (line-end-position))
      (setq unread-command-events (nconc (listify-key-sequence
                                          (this-command-keys))
                                         unread-command-events)))
  (call-interactively 'self-insert-command)))

For it to work I had to redirect self-insert-command which manual says against,
but seems to work fine here.

No idea if the implementation is the most elegant thing one could come up
with, and there is maybe a better way, but this one seems to work.

I am not at home, so I can't make a patch, I don't have entire source here
so I was just playing with my working file. I have attached it if someone would
be nice to test it. Can make a patch early next week if this is acceptable.


Från: Stefan Monnier <monnier@iro.umontreal.ca>
Skickat: den 19 mars 2021 22:58
Till: arthur miller <arthur.miller@live.com>
Kopia: emacs-devel@gnu.org <emacs-devel@gnu.org>
Ämne: Re: Sv: Partial wdired (edit just filename at the point)
 
> Yes, of course, I had `wdired-allow-to-change-permissions' set to t; it is the pre-requisita.

Well, I first tried it "as-is" and was quite perplexed until I saw that
I needed to set `wdired-allow-to-change-permissions` before anything
would have a chance of working ;-)

> Ok, originally permissions flags are preprocessed before change to wdired is
> finalized. So something somewhere in
> wdired setup is checking for permission bits? I think.

It's simply that the way the edition of permissions works when
`wdired-allow-to-change-permissions' is set to t is that wdired places
a `keymap` property on those permissions.  This way when you hit `x`
while point is in that area, it doesn't run `self-insert-command` but
`wdired-set-bit` (which edits the buffer manually with
inhibit-read-only).

But with the new code, that `keymap` property is not added right away,
so `x` works if that line has already been processed by our
`dired--before-change-fn` but not otherwise, because there's no `keymap`
property yet and hence the `x` runs `self-insert-command` rather than
`wdired-set-bit`.


        Stefan

Attachment: partial-wdired.el
Description: partial-wdired.el


reply via email to

[Prev in Thread] Current Thread [Next in Thread]