From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Point at beginning of search pattern incompatible with M-p Date: Sat, 06 Oct 2012 20:31:11 +0300 Organization: JURTA Message-ID: <871uhbfqvw.fsf@mail.jurta.org> References: <80mx00ug23.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1349544858 13306 80.91.229.3 (6 Oct 2012 17:34:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Oct 2012 17:34:18 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Sebastien Vauban" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 06 19:34:22 2012 Return-path: Envelope-to: ged-emacs-devel@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 1TKYGY-0002bx-Gv for ged-emacs-devel@m.gmane.org; Sat, 06 Oct 2012 19:34:18 +0200 Original-Received: from localhost ([::1]:55645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKYGS-0006hZ-M1 for ged-emacs-devel@m.gmane.org; Sat, 06 Oct 2012 13:34:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKYGQ-0006hU-Nr for emacs-devel@gnu.org; Sat, 06 Oct 2012 13:34:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TKYGP-0000nd-PO for emacs-devel@gnu.org; Sat, 06 Oct 2012 13:34:10 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:60368 helo=ps18281.dreamhostps.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKYGP-0000nT-Jp for emacs-devel@gnu.org; Sat, 06 Oct 2012 13:34:09 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 0241E451C23C; Sat, 6 Oct 2012 10:34:06 -0700 (PDT) In-Reply-To: <80mx00ug23.fsf@somewhere.org> (Sebastien Vauban's message of "Sat, 06 Oct 2012 11:04:52 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 69.163.218.105 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:154132 Archived-At: > I had, for some time, the following code in my .emacs. > > The goal: always exit searches at the beginning of the expression found. > > (add-hook 'isearch-mode-end-hook 'custom-goto-match-beginning) > > (defun custom-goto-match-beginning () > "Use with isearch hook to end search at first char of match." > (when isearch-forward (goto-char isearch-other-end))) > > Problem: when I want to reuse earlier search strings (with the command `M-p'), > I get the following error: > [...] > Can this be fixed somehow, to enjoy both features (exiting searches at the > beginning of the expression, and reusing earlier search strings) together? I for one have this code in ~/.emacs that could help you to do what you want: (define-key isearch-mode-map [(control return)] 'isearch-exit) ;; C-RET doesn't add the current search string to the search ring ;; and moves point to the beginning of the found search string. (add-hook 'isearch-mode-end-hook (lambda () ;; Exiting isearch with C-RET (when (eq last-input-event 'C-return) ;; Move point to the beginning of the found search string (if (and isearch-forward isearch-other-end) (goto-char isearch-other-end)) ;; Don't add the current search string to the search ring (if isearch-regexp (setq regexp-search-ring (cdr regexp-search-ring)) (setq search-ring (cdr search-ring)))))) Not sure about turning this into some configurable options.