[Top][All Lists]

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

bug#7503: copy-and-insert-previous-line

Subject: bug#7503: copy-and-insert-previous-line
Date: Sun, 28 Nov 2010 16:05:34 -0500

    I think such differences is the reason why such commands are not
    very good candidates for inclusion in Emacs: there are so many
    different commands that do something along these lines, that
    adding them all would not make much sense.

FWIW following is my more generalized take on Andreas' and Mads' versions.

This one:
 - Doesn't step on the kill-ring;
 - Has option to keep/omit text-props;
 - inserts only when asked to do so:

;;; <Timestamp: #{2010-11-28T12:10:07-05:00Z}#{10477} - by MON>
(defun line-previous-duplicate (&optional keep-props insrtp intrp)
  "Return content of previous line.
When optional arg KEEP-PROPS is non-nil return value is as if by
`buffer-substring'.  Default is as if by `buffer-substring-no-properties'.
When optional arg INSRTP is non-nil or called-interactively, insert return value
at point. Does not move point."
  (interactive "*i\ni\np")
    (let ((lpd-psns `(,(progn (forward-line -1) (point)) .
                      ,(progn (forward-line 1) (point)))))
      (set (or (and intrp  (quote intrp))
               (and insrtp (quote insrtp))
               (and (set (quote intrp) (quote insrtp))
                    (quote insrtp)))
           (or (and keep-props
                    (buffer-substring (car lpd-psns) (cdr lpd-psns)))
                (car lpd-psns) (cdr lpd-psns)))))
    (or (and (not (eq intrp 'insrtp))
             (stringp insrtp)
             (insert insrtp))
        (and intrp
             (stringp intrp)
             (insert intrp))


reply via email to

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