unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* yank-repeat-newline
@ 2011-07-26 19:12 Andreas Röhler
  2011-07-26 19:19 ` yank-repeat-newline Teemu Likonen
  2011-07-26 19:32 ` yank-repeat-newline Drew Adams
  0 siblings, 2 replies; 7+ messages in thread
From: Andreas Röhler @ 2011-07-26 19:12 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org List

Hi,

there was a thread "repeating yank" on this list, which resulted here in 
two functions:

(defun yank-repeat (arg)
   "With numerical ARG, repeat last yank ARG times. "
   (interactive "p*")
   (dotimes (i arg)
     (insert (car kill-ring))))

(defun yank-repeat-newline (arg)
   "With numerical ARG, repeat last yank ARG times,
also insert a newline. "
   (interactive "p*")
   (dotimes (i arg)
     (insert (concat (car kill-ring) "\n"))))

Now when trying to combine both, get difficulties

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

What is the recommended way writing that?

Thanks,

Andreas

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



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

end of thread, other threads:[~2011-07-26 20:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-26 19:12 yank-repeat-newline Andreas Röhler
2011-07-26 19:19 ` yank-repeat-newline Teemu Likonen
2011-07-26 19:24   ` yank-repeat-newline Andreas Röhler
2011-07-26 19:35     ` yank-repeat-newline Teemu Likonen
2011-07-26 19:45       ` yank-repeat-newline Andreas Röhler
2011-07-26 20:33         ` yank-repeat-newline Drew Adams
2011-07-26 19:32 ` yank-repeat-newline Drew Adams

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