From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: stromme@mi.uib.no (Stein A. Stromme) Newsgroups: gmane.emacs.help Subject: Re: Copy and Pasting in Emacs... Date: Mon, 08 Mar 2004 15:00:57 +0100 Organization: Univ. of Bergen, Dept. of Mathematics Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <94740f05.0403071520.5069e469@posting.google.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1079005615 12044 80.91.224.253 (11 Mar 2004 11:46:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Mar 2004 11:46:55 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 11 12:46:50 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B1OeI-0003xc-00 for ; Thu, 11 Mar 2004 12:46:50 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B1N5v-0001Dx-SD for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Mar 2004 05:07:15 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!uninett.no!nntp.uib.no!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Original-NNTP-Posting-Host: eliud.mi.uib.no Original-X-Trace: toralf.uib.no 1078754236 7805 129.177.61.66 (8 Mar 2004 13:57:16 GMT) Original-X-Complaints-To: abuse@uib.no Original-NNTP-Posting-Date: 8 Mar 2004 13:57:16 GMT User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:eX0+VHxNSyF7f2XB764SxXUbFl8= Original-Xref: shelby.stanford.edu gnu.emacs.help:121530 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:17525 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:17525 [Stefan Monnier on copying a line] | Stefan "who'd use C-k C-y to copy and then C-y to yank" I have this in my .emacs, stolen from Xemacs but works in GNU Emacs as well: ;;; Utility from xemacs/lisp/misc.el (defun copy-from-above-command (&optional arg) "Copy characters from previous nonblank line, starting just above point. Copy ARG characters, but not past the end of that line. If no argument given, copy the entire rest of the line. The characters copied are inserted in the buffer before point." (interactive "P") (let ((cc (current-column)) n (string "")) (save-excursion (beginning-of-line) (backward-char 1) (skip-chars-backward "\ \t\n") (move-to-column cc) ;; Default is enough to copy the whole rest of the line. (setq n (if arg (prefix-numeric-value arg) (point-max))) ;; If current column winds up in middle of a tab, ;; copy appropriate number of "virtual" space chars. (if (< cc (current-column)) (if (eq (char-before (point)) ?\t) (progn (setq string (make-string (min n (- (current-column) cc)) ?\ )) (setq n (- n (min n (- (current-column) cc))))) ;; In middle of ctl char => copy that whole char. (backward-char 1))) (setq string (concat string (buffer-substring (point) (min (save-excursion (end-of-line) (point)) (+ n (point))))))) (insert string))) (define-key global-map [(insert)] 'copy-from-above-command) So to copy a line I move point below the line and do C-o (if necessary, to make space for the new line) and then [insert]. (Feel free to use a different keystroke if you actually need the insert key for something else.) Of course this is only useful if you really want the new copy to come immediately after the original, but I find this often to be the case. SA -- Stein Arild Strømme +47 55584825, +47 95801887 Universitetet i Bergen Fax: +47 55589672 Matematisk institutt www.mi.uib.no/stromme/ Johs Brunsg 12, N-5008 BERGEN stromme@mi.uib.no