all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Le Wang <l26wang@gmail.com>
To: Alan <bowl.of.petunias@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Copying a whole line using kill-ring-save in emacs 24.3.1
Date: Mon, 18 Mar 2013 23:30:26 +0800	[thread overview]
Message-ID: <CAM=K+irSmVDA85wgw7i3LkviSbeoLumMfSaAm2U29E6=qscUqg@mail.gmail.com> (raw)
In-Reply-To: <CABOjsxnc5izxHSTEcL218tKiHgMszuVkGrzLUWV2Jy01D5Zvgw@mail.gmail.com>

On Sun, Mar 17, 2013 at 4:01 PM, Alan <bowl.of.petunias@gmail.com> 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 the
> 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:
> “Wrong type argument: integer-or-marker-p, nil”, although it does
> successfully copy the line. However, further “meta-w” presses copy from the
> current position to the last mark, regardless of whether the region is
> highlighted.
>
> Any thoughts on getting the “Meta-w” 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 of
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)



-- 
Le



  reply	other threads:[~2013-03-18 15:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-17  8:01 Copying a whole line using kill-ring-save in emacs 24.3.1 Alan
2013-03-18 15:30 ` Le Wang [this message]
2013-03-19 20:07   ` Alan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM=K+irSmVDA85wgw7i3LkviSbeoLumMfSaAm2U29E6=qscUqg@mail.gmail.com' \
    --to=l26wang@gmail.com \
    --cc=bowl.of.petunias@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.