From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Le Wang Newsgroups: gmane.emacs.help Subject: Re: Copying a whole line using kill-ring-save in emacs 24.3.1 Date: Mon, 18 Mar 2013 23:30:26 +0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1363620661 21038 80.91.229.3 (18 Mar 2013 15:31:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Mar 2013 15:31:01 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Alan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 18 16:31:27 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UHc1y-0002pM-IC for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Mar 2013 16:31:22 +0100 Original-Received: from localhost ([::1]:59117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHc1b-0006u8-JW for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Mar 2013 11:30:59 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHc1G-0006ih-Ow for help-gnu-emacs@gnu.org; Mon, 18 Mar 2013 11:30:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHc1B-0008SJ-F0 for help-gnu-emacs@gnu.org; Mon, 18 Mar 2013 11:30:38 -0400 Original-Received: from mail-wg0-f52.google.com ([74.125.82.52]:47107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHc1B-0008QW-9l for help-gnu-emacs@gnu.org; Mon, 18 Mar 2013 11:30:33 -0400 Original-Received: by mail-wg0-f52.google.com with SMTP id 15so4093491wgd.19 for ; Mon, 18 Mar 2013 08:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding; bh=YvDRteh2CdftqaYQ7jd96cEstVzGhQB5oT089/dZP4A=; b=arzP9g5O75yFs6bbb88UnNt+ATkfed1YqY5lM2+oQXmYbDe+JZq3j3ITJpeq2jl36m gaBx46shinXid6C+hWdWOLxoRBfZ4bWuZLjG31W/p25qD9Ji83femf2AU3Ud6gTJy6my rUvns/s22uq7/W3ZM8fKPAlDVRf98M/IVQQV4DXT3n/XcH8YVao+RBMnfvZ5feIIrEdh uieqEKlwMBar6t6rgTQye0HJSOFr2H04AjTsjgW7PB5vYhQgf5v4oxmg9XC7EDZfUxsV 9PO78hE5L/sA/HnBXDW+l9eSUOZlQniYNhR3/0b97D6gch/ORmdGioE+oJcfA52znYl4 vV9g== X-Received: by 10.194.82.34 with SMTP id f2mr25964391wjy.25.1363620626629; Mon, 18 Mar 2013 08:30:26 -0700 (PDT) Original-Received: by 10.216.122.74 with HTTP; Mon, 18 Mar 2013 08:30:26 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.82.52 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89581 Archived-At: On Sun, Mar 17, 2013 at 4:01 PM, Alan wrote: > Hi, > > I've used the following code, from > http://www.emacswiki.org/emacs/WholeLineOrRegion, to copy a whole line: > > (put 'kill-ring-save 'interactive-form > '(interactive > (if (use-region-p) > (list (region-beginning) (region-end)) > (list (line-beginning-position) (line-beginning-position 2))))) > > > Basically, it allows the use of "meta-w" to copy the entire line where th= e > cursor is currently located, as long as no text is visually selected. > (Transient Mark Mode must be enabled for this to work.) However, after > upgrading to emacs version 24.3.1 (from 24.2.1), this fails to work. > > When I visit a file for the first time and hit "meta-w", I get the error: > =93Wrong type argument: integer-or-marker-p, nil=94, although it does > successfully copy the line. However, further =93meta-w=94 presses copy fr= om the > current position to the last mark, regardless of whether the region is > highlighted. > > Any thoughts on getting the =93Meta-w=94 to work? Thanks. It looks like functionality has been added to highlight the region that was copied. The problem is your snippet relies on the implementation instead o= f the API. It's better to define your own command and remap. (defun my-kill-ring-save (beg end) (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (line-beginning-position) (line-beginning-position 2= )))) (kill-ring-save beg end)) (global-set-key [remap kill-ring-save] 'my-kill-ring-save) --=20 Le