From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Can I disable yank's automatic "set mark" Date: Wed, 10 Nov 2010 13:29:37 -0500 Organization: A noiseless patient Spider Message-ID: References: <4cda84d7$0$29178$c3e8da3$88b277c5@news.astraweb.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1291891308 478 80.91.229.12 (9 Dec 2010 10:41:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 10:41:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 11:41:45 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQdwV-0004bk-Uc for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 11:41:45 +0100 Original-Received: from localhost ([127.0.0.1]:60081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQdwU-0007Uw-FP for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 05:41:42 -0500 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 51 Injection-Info: mx03.eternal-september.org; posting-host="Mj7cfegjHp0n7K+H7O4DuQ"; logging-data="10417"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SwDs+jFiLkoShVzf8vvd3" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:eYx3C/AghtFyARMa+3FwL1Qx5DA= sha1:5TsNU0cVH7bjk02cpC3zQUA2Nqo= Original-Xref: usenet.stanford.edu gnu.emacs.help:182326 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:76963 Archived-At: > Whenever I yank (ctrl-y) text into a buffer, the mark is automatically > set. Is there any way to disable this behavior? Not directly, no. Here's how I found out: C-h k C-y told me that C-y is bound to `yank' defined in `simple.el'. So I clicked on `simple.el' which brought me to the simple.el file where it defines `yank'. That definition starts with a longish text (that same text you say in the *Help*), and then says: (interactive "*P") (setq yank-window-start (window-start)) ;; If we don't get all the way thru, make last-command indicate that ;; for the following command. (setq this-command t) (push-mark (point)) (insert-for-yank (current-kill (cond ((listp arg) 0) ((eq arg '-) -2) (t (1- arg))))) (if (consp arg) ;; This is like exchange-point-and-mark, but doesn't activate the mark. ;; It is cleaner to avoid activation, even though the command ;; loop would deactivate the mark because we inserted text. (goto-char (prog1 (mark t) (set-marker (mark-marker) (point) (current-buffer))))) ;; If we do get all the way thru, make this-command indicate that. (if (eq this-command t) (setq this-command 'yank)) nil) While you may not understand all of the code, you'll probaly notice that it says "(push-mark (point))" and that it says so without any intervening "if" or other conditional which means that it sets the mark without any way not to do it. So if you want to change it you have 2 solutions: create a new command `my-yank' which copies all the above code except for the push-mark call, or create a new command which calls `yank' and then undoes that push-mark, e.g. (defun my-yank () "Put your description here." (interactive) (yank) (pop-mark)) Stefan