unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: How can I contextually override shift selection functions?
@ 2019-08-05  6:19 ndame
  0 siblings, 0 replies; 4+ messages in thread
From: ndame @ 2019-08-05  6:19 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

> though I'm wondering why simply adding the caret to the interactive spec
> doesn't fix the  issue:
> 
>   (local-set-key (kbd "S-<down>") (lambda ()
>                                     (interactive "^")
>                                     (if (my-context)
>                                         (do 'something 'else)
>                                       
>                                       ;; call S-down as usual
>                                       (call-interactively 'next-line))))
>

Ah, I took a closer look and now it's obvious I shouldn't bind Shift+...
at all and then interactive magic works:


  (local-set-key (kbd "<down>") (lambda ()
                                  (interactive "^")
                                  (if (and this-command-keys-shift-translated (my-context))
                                      (do 'something 'else)
                                      
                                    ;; call down as usual
                                    (next-line))))



 


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: How can I contextually override shift selection functions?
@ 2019-08-04 20:04 ndame
  0 siblings, 0 replies; 4+ messages in thread
From: ndame @ 2019-08-04 20:04 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

(Sorry, I accidentally messed up the thread subject in the previous message.)


> Did you already study the handle-shift-selection function?

Thanks, I've taken a look and this seems to solve the issue:

   (let ((this-command-keys-shift-translated t))
     (call-interactively 'next-line)))))


though I'm wondering why simply adding the caret to the interactive spec
doesn't fix the  issue:

  (local-set-key (kbd "S-<down>") (lambda ()
                                    (interactive "^")
                                    (if (my-context)
                                        (do 'something 'else)
                                      
                                      ;; call S-down as usual
                                      (call-interactively 'next-line))))
 


^ permalink raw reply	[flat|nested] 4+ messages in thread
* How can I contextually override shift selection functions?
@ 2019-08-04 18:07 ndame
  2019-08-04 18:28 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: ndame @ 2019-08-04 18:07 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Let's say I want to add an override functionality of a shift
selection function. The shift selection handling is done by
interactive ^ trickery, and it's not obvious how to preempt it.

E.g. if I want to do something in certain contexts with S-down then
I'd say:


(local-set-key (kbd "S-<down>") (lambda ()
                                  (interactive)
                                  (if (my-context)
                                      (do 'something 'else)
                                    
                                    ;; call S-down as usual
                                    (call-interactively 'next-line))))


Only the thing is call-interactively does not work here, that is
it does not extend the selection when I press S-down.

How can I invoke then the original shift selection feature from a
program if I want to invoke the default behavior?


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

end of thread, other threads:[~2019-08-05  6:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-05  6:19 How can I contextually override shift selection functions? ndame
  -- strict thread matches above, loose matches on Subject: below --
2019-08-04 20:04 ndame
2019-08-04 18:07 ndame
2019-08-04 18:28 ` Eli Zaretskii

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