From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: bundling C-u C-space
Date: Mon, 12 Oct 2015 00:44:46 +0200 [thread overview]
Message-ID: <877fmt10v5.fsf@debian.uxu> (raw)
In-Reply-To: 20151010200341.GI3342@mail.akwebsoft.com
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
next prev parent reply other threads:[~2015-10-11 22:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2015-10-12 0:51 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877fmt10v5.fsf@debian.uxu \
--to=embe8573@student.uu.se \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).