all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

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.