From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Karl Fogel Newsgroups: gmane.emacs.devel Subject: Re: PATCH: isearch-yank-until-char Date: Mon, 26 Aug 2019 16:29:30 -0500 Message-ID: <87k1az8vk5.fsf@red-bean.com> References: <87tvakfnv4.fsf@red-bean.com> <87lfvvjxjs.fsf@mail.linkov.net> <87sgq1r9rb.fsf@red-bean.com> <87lfvt6m1e.fsf@mail.linkov.net> <877e7256uc.fsf@red-bean.com> <604cbbef-7e25-486a-a97a-9bc1adf23928@default> <871rx87b9h.fsf@red-bean.com> <77205e15-f38a-46dc-9451-4030a318900a@default> <874l23ak8m.fsf@red-bean.com> Reply-To: Karl Fogel Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="222390"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Emacs developers To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 26 23:30:20 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i2MZ9-000vi5-I9 for ged-emacs-devel@m.gmane.org; Mon, 26 Aug 2019 23:30:19 +0200 Original-Received: from localhost ([::1]:57840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2MZ8-0003jF-5n for ged-emacs-devel@m.gmane.org; Mon, 26 Aug 2019 17:30:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38310) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2MYR-0003j5-FZ for emacs-devel@gnu.org; Mon, 26 Aug 2019 17:29:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2MYQ-0000jS-3v for emacs-devel@gnu.org; Mon, 26 Aug 2019 17:29:35 -0400 Original-Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]:35068) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2MYP-0000j4-UR for emacs-devel@gnu.org; Mon, 26 Aug 2019 17:29:34 -0400 Original-Received: by mail-io1-xd29.google.com with SMTP id b10so31999565ioj.2 for ; Mon, 26 Aug 2019 14:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:reply-to:date:in-reply-to :message-id:user-agent:mime-version; bh=v1AVPXt+IhtJP7m14HmIBzgZJk27pZ9g2pnrcHCykHo=; b=qsD4i5tazdRDbTiMtI1UDI2t6X9Jb+nCK8zZgHxfMDbr7bxP69mR6En28N8+BvWORJ knZJ7qOGRebbllH1Me5BVHgdIaZVyDXAuRA5Axrb/MMEKSUkPDXETIt979juHIc3bOIr Wp3Yp0sQTG03sxXAy7WyYrT/rGzbbY0+B3V11Awc6i043XPnaNN/nY6iNrsaxQhh/0op AWw0Y9eqi9ih+wHMKumi4HhsVRzfeFs63xpk0hyuLs6Kze2myxVSPbpilF/e8a9P/610 vijdTko8C5wky5vzgW6M2e3AxDSwPBvVbOA9pVjD0IAHnbEt8z7fJsgEgwEpBkYKSr+n TwZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:reply-to :date:in-reply-to:message-id:user-agent:mime-version; bh=v1AVPXt+IhtJP7m14HmIBzgZJk27pZ9g2pnrcHCykHo=; b=UJkgaFS4mWpX8gvnnnlMKLduur8fq7Ayl5y5iXmmtrZ61TrcXp+3nvphCotBpvWdYT 0guYky4cPb2h9O1fmzKjB5G73FhHn3jxfxGVWvCbWM9pxFAoFDaqi4TPAddSEH/MNFEV 8+u1iMcbr4nvSgVLDpFuWTkxE15hNsQMFG5QB2HG97hH/HAwsNqQG6PANhDnRcQ6S01p OBKmnhZ0rKQTt+AXohTyjDbUU5NZxWtXnjMqcFhJZmW/v60TB8iVOwcv1YhCci+MeLVF jZcy1LTPd1jlYHPrMhyfH+slkWIjSSNo/Dj1UdnDg7Okl431NhPmgdTHjkjt89BgSHw2 jgog== X-Gm-Message-State: APjAAAULFQZuJ87ieH9sYJi6SY9RIQmd+o4SjABVwPVJNbu0epwSGO3r r5YB3IFdBqLv86an2zdtFEoItgA+ X-Google-Smtp-Source: APXvYqx6EqfCpcFCUKAAa12t7yvznjipTrTAr4UmtX8f6aASlpsz6NBWwJWzreDKym9/PMKZtEtDUw== X-Received: by 2002:a05:6602:25d3:: with SMTP id d19mr28063486iop.206.1566854972765; Mon, 26 Aug 2019 14:29:32 -0700 (PDT) Original-Received: from kwork (74-92-190-114-Illinois.hfc.comcastbusiness.net. [74.92.190.114]) by smtp.gmail.com with ESMTPSA id e12sm12304107iob.66.2019.08.26.14.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 14:29:31 -0700 (PDT) In-Reply-To: (Drew Adams's message of "Mon, 26 Aug 2019 12:36:23 -0700 (PDT)") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d29 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.org gmane.emacs.devel:239591 Archived-At: --=-=-= Content-Type: text/plain On 26 Aug 2019, Drew Adams wrote: >OK. > >(But I can guess the outcome. It's OK; I can always >just add the enhancement to isearch+.el. It won't be >the first time.) Well, I can't say what the outcome would be, but in any case that shouldn't be affected by the order in which we do these things. >FYI, it doesn't do that in the parts that are doc. >Those patch parts still speak of `C-M-c'. Gah -- I rushed. Thank you for noticing that. New patch attached. >> * Make the search for the character case-sensitive. (Seems like a >> pretty obvious improvement, given the use cases: when the goal >> character is a letter at all, one is either looking at that letter on >> the screen *or* the letter is some known syntactic delimiter and its >> case is therefore known as well even if the letter is off the screen >> right now.) > >FWIW, I don't think that's really TRT. > >Personally, I have `case-fold-search' set to nil by >default, so that behavior isn't a problem for me. >But I don't think it should be part of this command. > >Users can toggle case-folding in Isearch easily. > >There's no reason to have this command make an >assumption about whether its char-search should be >case-sensitive. I don't think the either...or >assumption you made above is good for the command >to make. Better to let users control whether to >search for the char case-sensitively. When I think about the circumstances under which this command is actually used, which I tried to characterize above, I couldn't think of any in which case-insensitive matching would make sense -- speaking of just the char-match, of course, not the overall isearch. The overall isearch still obeys `isearch-case-fold-search'. When the user toggles case-folding in isearch, that should and does affect the isearch itself, but that isn't the same as the single-char match-and-yank-into-search-string we're talking about here. For the latter, case-sensitivity makes sense I think. Can you say which part of the assumptions I gave above seems wrong to you? Best regards, -Karl --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=isearch-yank-until-char-20190826-2.txt [[[ Add `isearch-yank-until-char' * lisp/isearch.el (isearch-yank-until-char): New function. (isearch-mode-map, isearch-menu-bar-yank-map): Add it. (isearch-forward): Document the new binding. * doc/emacs/search.texi (Isearch Yanking): Document the feature. * etc/NEWS: Mention the above. ]]] --- doc/emacs/search.texi +++ doc/emacs/search.texi @@ -262,11 +262,17 @@ Isearch Yank @kindex M-s C-e @r{(Incremental search)} @findex isearch-yank-line - Similarly, @kbd{M-s C-e} (@code{isearch-yank-line}) appends the rest + @kbd{M-s C-e} (@code{isearch-yank-line}) appends the rest of the current line to the search string. If point is already at the end of a line, it appends the next line. With a prefix argument @var{n}, it appends the next @var{n} lines. +@kindex C-M-. @r{(Incremental search)} +@findex isearch-yank-until-char + Similarly, @kbd{C-M-.} (@code{isearch-yank-until-char}) appends to +the search string everything from point until the next occurence of +a specified character (not including that character). + @kindex C-y @r{(Incremental search)} @kindex M-y @r{(Incremental search)} @kindex mouse-2 @r{in the minibuffer (Incremental search)} --- etc/NEWS +++ etc/NEWS @@ -1202,6 +1202,10 @@ highlight in one iteration while processing the full buffer. +++ *** New isearch bindings. +'C-M-.' invokes new function 'isearch-yank-until-char', which yanks +everything from point to the specified character into the search +string. + 'C-M-w' in isearch changed from 'isearch-del-char' to the new function 'isearch-yank-symbol-or-char'. 'isearch-del-char' is now bound to 'C-M-d'. --- lisp/isearch.el +++ lisp/isearch.el @@ -514,6 +514,9 @@ isearch-menu-bar-yank-map (define-key map [isearch-yank-kill] '(menu-item "Current kill" isearch-yank-kill :help "Append current kill to search string")) + (define-key map [isearch-yank-until-char] + '(menu-item "Until char..." isearch-yank-until-char + :help "Yank from point to specified character into search string")) (define-key map [isearch-yank-line] '(menu-item "Rest of line" isearch-yank-line :help "Yank the rest of the current line on search string")) @@ -705,6 +708,7 @@ isearch-mode-map (define-key map "\M-\C-d" 'isearch-del-char) (define-key map "\M-\C-y" 'isearch-yank-char) (define-key map "\C-y" 'isearch-yank-kill) + (define-key map [?\C-\M-.] 'isearch-yank-until-char) (define-key map "\M-s\C-e" 'isearch-yank-line) (define-key map "\M-s\M-<" 'isearch-beginning-of-buffer) @@ -998,6 +1002,8 @@ isearch-forward Type \\[isearch-del-char] to delete character from end of search string. Type \\[isearch-yank-char] to yank char from buffer onto end of search\ string and search for it. +Type \\[isearch-yank-until-char] to yank from point until the next instance\ + of a specified character onto end of search string and search for it. Type \\[isearch-yank-line] to yank rest of line onto end of search string\ and search for it. Type \\[isearch-yank-kill] to yank the last string of killed text. @@ -2562,6 +2568,22 @@ isearch-yank-word (interactive "p") (isearch-yank-internal (lambda () (forward-word arg) (point)))) +(defun isearch-yank-until-char (char) + "Pull everything until next instance of CHAR from buffer into search string. +Interactively, prompt for CHAR." + (interactive "cYank until character: ") + (isearch-yank-internal + (lambda () (let ((inhibit-field-text-motion t) + (case-fold-search nil)) + (condition-case nil + (progn + (search-forward (char-to-string char)) + (forward-char -1)) + (search-failed + (message "`%c' not found" char) + (sit-for 2))) + (point))))) + (defun isearch-yank-line (&optional arg) "Pull rest of line from buffer into search string. If optional ARG is non-nil, yank the next ARG lines." --=-=-=--