* bundling C-u C-space
@ 2015-10-10 20:03 Tim Johnson
2015-10-10 20:30 ` Drew Adams
2015-10-11 22:44 ` Emanuel Berg
0 siblings, 2 replies; 8+ messages in thread
From: Tim Johnson @ 2015-10-10 20:03 UTC (permalink / raw)
To: Emacs
Using GNU Emacs 24.3.1 on ubuntu 14.04
I'd like to get the functionality of Control-u Control-space in one
keystroke (for instance, Control-,) but can't wrap my thoughts about
how to put that in a lambda or use-defined function.
Because the larger question is about how to automate
'universal-argument, I'm sure the solution would edify me above and
beyond this simple need.
Pointers to docs and examples may be sufficient.
thanks
--
Tim
http://www.akwebsoft.com, http://www.tj49.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: bundling C-u C-space
2015-10-10 20:03 bundling C-u C-space Tim Johnson
@ 2015-10-10 20:30 ` Drew Adams
2015-10-10 20:36 ` Drew Adams
2015-10-11 22:44 ` Emanuel Berg
1 sibling, 1 reply; 8+ messages in thread
From: Drew Adams @ 2015-10-10 20:30 UTC (permalink / raw)
To: Tim Johnson, Emacs
> I'd like to get the functionality of Control-u Control-space in one
> keystroke (for instance, Control-,)
(global-set-key (kbd "C-,") 'pop-to-mark-command)
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: bundling C-u C-space
2015-10-10 20:30 ` Drew Adams
@ 2015-10-10 20:36 ` Drew Adams
2015-10-10 21:24 ` Tim Johnson
0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2015-10-10 20:36 UTC (permalink / raw)
To: Drew Adams, Tim Johnson, Emacs
> > I'd like to get the functionality of Control-u Control-space in
> > one keystroke (for instance, Control-,)
>
> (global-set-key (kbd "C-,") 'pop-to-mark-command)
BTW, you could discover `pop-to-mark-command' (it is not mentioned
in the manual) this way:
C-h k C-@
tells you that that command is `set-mark-command'.
Click the link in buffer *Help* that takes you to the command
definition in `simple.el'.
M-x debug-on-entry set-mark-command
C-u C-@
and walk through the debugger, to see what functions are used
to provide the behavior. You'll see that only function
`pop-to-mark-command' is invoked.
It's name suggests that it might be a command, but
`C-h f pop-to-mark-command' confirms this. It is all you need.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: bundling C-u C-space
2015-10-10 20:36 ` Drew Adams
@ 2015-10-10 21:24 ` Tim Johnson
2015-10-10 21:51 ` Drew Adams
0 siblings, 1 reply; 8+ messages in thread
From: Tim Johnson @ 2015-10-10 21:24 UTC (permalink / raw)
To: Emacs
* Drew Adams <drew.adams@oracle.com> [151010 12:47]:
> > > I'd like to get the functionality of Control-u Control-space in
> > > one keystroke (for instance, Control-,)
> >
> > (global-set-key (kbd "C-,") 'pop-to-mark-command)
>
> BTW, you could discover `pop-to-mark-command' (it is not mentioned
> in the manual) this way:
>
> C-h k C-@
> tells you that that command is `set-mark-command'.
>
> Click the link in buffer *Help* that takes you to the command
> definition in `simple.el'.
>
> M-x debug-on-entry set-mark-command
>
> C-u C-@
>
> and walk through the debugger, to see what functions are used
> to provide the behavior. You'll see that only function
> `pop-to-mark-command' is invoked.
>
> It's name suggests that it might be a command, but
> `C-h f pop-to-mark-command' confirms this. It is all you need.
As I expected ... additional edification.
Do I understand correctly that 4 is the default value when C-u is
used without a value
as in C-u C-@
?
Thanks, Drew
--
Tim
http://www.akwebsoft.com, http://www.tj49.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: bundling C-u C-space
2015-10-10 21:24 ` Tim Johnson
@ 2015-10-10 21:51 ` Drew Adams
2015-10-10 22:51 ` Tim Johnson
0 siblings, 1 reply; 8+ messages in thread
From: Drew Adams @ 2015-10-10 21:51 UTC (permalink / raw)
To: Tim Johnson, Emacs
> Do I understand correctly that 4 is the default value when C-u is
> used without a value as in C-u C-@?
4 is the numeric value of the prefix arg in that case. However, the
list (4) is the raw prefix argument value in that case.
See node `Prefix Command Arguments' of the Elisp manual:
C-h i
Choose Elisp manual.
i prefix argument RET
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: bundling C-u C-space
2015-10-10 21:51 ` Drew Adams
@ 2015-10-10 22:51 ` Tim Johnson
0 siblings, 0 replies; 8+ messages in thread
From: Tim Johnson @ 2015-10-10 22:51 UTC (permalink / raw)
To: help-gnu-emacs
* Drew Adams <drew.adams@oracle.com> [151010 14:00]:
> > Do I understand correctly that 4 is the default value when C-u is
> > used without a value as in C-u C-@?
>
> 4 is the numeric value of the prefix arg in that case. However, the
> list (4) is the raw prefix argument value in that case.
>
> See node `Prefix Command Arguments' of the Elisp manual:
>
> C-h i
> Choose Elisp manual.
> i prefix argument RET
thanks very much Drew
--
Tim
http://www.akwebsoft.com, http://www.tj49.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: bundling C-u C-space
2015-10-10 20:03 bundling C-u C-space Tim Johnson
2015-10-10 20:30 ` Drew Adams
@ 2015-10-11 22:44 ` Emanuel Berg
2015-10-12 0:51 ` Emanuel Berg
1 sibling, 1 reply; 8+ messages in thread
From: Emanuel Berg @ 2015-10-11 22:44 UTC (permalink / raw)
To: help-gnu-emacs
Tim Johnson <tim@akwebsoft.com> writes:
> I'd like to get the functionality of Control-u
> Control-space in one keystroke (for instance,
> Control-,) but can't wrap my thoughts about how to
> put that in a lambda or use-defined function.
In general, if you want to emulate a function's
behavior in the face of a prefix argument supplying
data, find out what that function is and supply that
data yourself!
C-SPC is `set-mark-command', so that would be
(set-mark-command '(4))
Why '(4) and not 4? Use the source, Luke!
For set-mark-command, it is
(interactive "P")
and not "p".
Test this with these - evaluate, and then call with M-x!
(defun test-prefix-from-code (arg)
(interactive "P")
(if arg (message "arg is %s - i.e., data is %s" arg (prefix-numeric-value arg))
(message "No arg, dammit!") ))
(defun test-prefix-from-code-not-raw (arg)
(interactive "p")
(message "arg is %s - i.e., data is %s" arg (prefix-numeric-value arg)) )
;; note: no `if' form! arg will be 1 if not
;; supplied, and not nil as above!
And now something else:
Sometimes the ARG isn't exactly to supply data but to
control behavior. Then instead of supplying the "data"
that by all means get you the behavior you want,
instead you can examine the source - again - and
simply detect the function that does what you want.
If the code is neatly written it shouldn't be
a problem detecting and isolating it.
In this case, is it `pop-to-mark-command'?
Good luck!
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: bundling C-u C-space
2015-10-11 22:44 ` Emanuel Berg
@ 2015-10-12 0:51 ` Emanuel Berg
0 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2015-10-12 0:51 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <embe8573@student.uu.se> writes:
> Why '(4) and not 4? Use the source, Luke!
> For set-mark-command, it is
>
> (interactive "P")
>
> and not "p".
By the way, here is an even better example which shows
the power of not pi but "p":
(defun window-increase-size (lines)
(interactive "p")
(window-resize nil lines) )
(defun window-decrease-size (lines)
(interactive "p")
(window-resize nil (* -1 lines) ))
(nil = current window!)
After you bind these to keystrokes, you can brute
hammer them keys until the window is of the right
size, *or* you can be mindful Jedi Master Kublai Khan
and shamanize exactly how many lines are needed, and
then hammer (or caress rather) that into action as the
prefix argument! You see? Poet and killer!
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-10-12 0:51 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-10 20:03 bundling C-u C-space Tim Johnson
2015-10-10 20:30 ` Drew Adams
2015-10-10 20:36 ` Drew Adams
2015-10-10 21:24 ` Tim Johnson
2015-10-10 21:51 ` Drew Adams
2015-10-10 22:51 ` Tim Johnson
2015-10-11 22:44 ` Emanuel Berg
2015-10-12 0:51 ` Emanuel Berg
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).