all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: Emacs developers <emacs-devel@gnu.org>
Subject: more than one prefix argument
Date: Tue, 26 Jul 2011 21:59:08 +0200	[thread overview]
Message-ID: <4E2F1C8C.9010802@easy-emacs.de> (raw)

Hi,

what about allowing more than one prefix argument
by making interactive codes "p" and "P" sending
truly separated.

Would reserve "p" for numerical args, while "P"
basically should send a kind of exception flag,
branching execution.

Below a use-case for it, yank-repeat should add
newlines if C-u follows the numeric argument.

As both inputs interfere, that's not possible that way
for now.

;; not working now
(defun yank-repeat-newline (arg &optional nl)
   "With numerical ARG, repeat last yank ARG times.
With optional arg NL, also insert newlines. "
   (interactive "p\nP*")
   (let ((nl nl)
         (num arg))
     (dotimes (i num)
       (if nl
           (insert (concat (car kill-ring) "\n"))
         (insert (car kill-ring))))))


Drew presented a solution at help-gnu-emacs@gnu.org:

;;;;;;;;;;;;;;;;;

As Teemu explained, there is only _one_ prefix arg. You can look at 
either its
numeric value or its raw value or both, but there is only ONE prefix arg.

You apparently want to have a prefix arg express both a numeric quantity 
and a
boolean.  If the user uses C-u (or its variants) to specify a (non-nil) 
prefix
arg then, well, the raw value is non-nil.  If the raw value is nil, then the
user did not use C-u (or its variants).

If you want to let the user specify a numeric value, default 1, and also 
specify
whether to add a newline, then one way to do that is to distinguish positive
from negative prefix arg (there's your boolean).

E.g.:

M-x yank...    -> just one, no newline
M-- yank...    -> one, newline
C-u -1 yank... -> one, newline
C-u -2 yank... -> two, newlines
C-u  2 yank... -> two, no newlines

Something like this:

(defun myyank (&optional arg)
   (interactive "p")
   (dotimes (i (abs arg))
     (if (natnump arg)
	(insert (car kill-ring))
       (insert (concat (car kill-ring) "\n")))))

;;;;;;;;;;;;;

However, that solution seems too complicated for a
part of non-programmers, it's not mnemonic, rather
tricky - even not uncommon in Emacs.

Would be glad to have C-u as general branch key.

Thanks all,

Andreas

--
https://launchpad.net/python-mode
https://launchpad.net/s-x-emacs-werkstatt/



             reply	other threads:[~2011-07-26 19:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-26 19:59 Andreas Röhler [this message]
2011-07-26 20:10 ` more than one prefix argument Daniel Colascione
2011-07-26 20:36   ` Andreas Röhler
2011-07-26 20:57     ` Drew Adams
2011-07-26 20:36   ` Drew Adams
2011-07-27  6:25     ` Andreas Röhler
2011-07-27  9:25       ` Tim Cross
2011-07-27  9:37         ` Andreas Röhler
2011-07-27  9:48           ` Tim Cross
2011-07-27 10:21             ` Andreas Röhler
2011-07-27 11:21               ` Andreas Schwab
2011-07-27 11:46                 ` Andreas Röhler
2011-07-27 12:39                   ` Andreas Schwab
2011-07-27 12:51                   ` Tim Cross
2011-07-27 12:46               ` Tim Cross
2011-07-27 15:09               ` Drew Adams
2011-07-27  9:38         ` Tim Cross

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E2F1C8C.9010802@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=emacs-devel@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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.