GNU bug report logs - #7503
copy-and-insert-previous-line

Previous Next

Package: emacs;

Reported by: Mads Jensen <mje <at> inducks.org>

Date: Sun, 28 Nov 2010 10:23:01 UTC

Severity: wishlist

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: MON KEY <monkey <at> sandpframing.com>
To: 7503 <at> debbugs.gnu.org
Cc: mje <at> inducks.org, rudalics <at> gmx.at, schwab <at> linux-m68k.org, monnier <at> iro.umontreal.ca, eliz <at> gnu.org, sdl.web <at> gmail.com
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")
  (save-excursion
    (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)))
               (buffer-substring-no-properties
                (car lpd-psns) (cdr lpd-psns)))))
    (or (and (not (eq intrp 'insrtp))
             (stringp insrtp)
             (insert insrtp))
        (and intrp
             (stringp intrp)
             (insert intrp))
        insrtp)))

--
/s_P\




This bug report was last modified 11 years and 110 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.