[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Andreas Röhler
Subject: yank-repeat-newline
Date: Tue, 26 Jul 2011 21:12:35 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv: Gecko/20110616 SUSE/3.1.11 Thunderbird/3.1.11


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?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]