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: PATCH: isearch-yank-until-char Date: Tue, 13 Aug 2019 22:05:19 -0500 Message-ID: <87tvakfnv4.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="243217"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 14 05:06:01 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 1hxjbr-00116o-Ul for ged-emacs-devel@m.gmane.org; Wed, 14 Aug 2019 05:06:00 +0200 Original-Received: from localhost ([::1]:56926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hxjbq-0002vS-6D for ged-emacs-devel@m.gmane.org; Tue, 13 Aug 2019 23:05:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58084) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hxjbI-0002vC-Dx for emacs-devel@gnu.org; Tue, 13 Aug 2019 23:05:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxjbH-0007vg-2z for emacs-devel@gnu.org; Tue, 13 Aug 2019 23:05:24 -0400 Original-Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]:39951) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hxjbG-0007vU-RZ for emacs-devel@gnu.org; Tue, 13 Aug 2019 23:05:23 -0400 Original-Received: by mail-ot1-x333.google.com with SMTP id c34so39042416otb.7 for ; Tue, 13 Aug 2019 20:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:reply-to:date:message-id:user-agent :mime-version; bh=1VbgZz7k8vprCqN0AU76S3rZcvg6A8gLkNgEcmIxrOI=; b=Dx8VQTtW0XccFgc+RietKhdfOXpeOR+s585wLgZVTXQ7Z1LNUZgWS8/BNfss5XKLPn ClGU4PhkaOdEniDHAvZAvfKwlDEI3VAwT1J5nkL7LWx25jkwcWE9efwMAFKZQoQQmXNN ZPJnG3U/tl9j3X5dtV/8LPX37Eog9h3TRi3rXOFPb4HE/JtoJq+SAcL+rfedZJOTT4NW qsitg8dFXI/+bleHFDZaNqrGxWg6Dtd/g2WFa1Hpn/b2KkGRIzdId9eyhoEGnXLQx/g7 GYsc6UM3EXtXgJYUmdMEcywmnqtqUwv/7tY1iBkpJ1J5ROEDkBIZeOczOyy3eKQdy8an a8HQ== 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:subject:reply-to:date:message-id :user-agent:mime-version; bh=1VbgZz7k8vprCqN0AU76S3rZcvg6A8gLkNgEcmIxrOI=; b=dRwuFalxkROZkDz7bS+pjRWjraxfiTRZisJDokvwbQoiCt190Ub8Aa5hz/Cr9KXV7i pNX4xDjr9Yfrhlo23tCCOLOoGkPl9aUzY6C+WQZKwdHG/LJVZs4uhVF95QCNEtcCwqr1 5DleiYOwkngPg4gM7vtU3perFj9UwAht2xisMJbSeWL55JG4gxyJTO5Who/mQZ/vT7Px 28AKwjuJIcPtfEuzQQPbApRBe/d6Uf3KPe+jeAEG/u7ZpXuxH6+jX97snr3nCNbCMPet 1eUk2HQc+PBQcTAITu1qyYvhwcyp7ZeHKVKmO4SxzupvzkzE2l12U0TW6btFYESYynRR 5xoQ== X-Gm-Message-State: APjAAAUQaxC1J6hLZPj9REhZ5JjWfPzneuLXnETdk/HgV3l7StBb0Jpn tYT4QibExYkrtw1z3/IBVYt14zkx X-Google-Smtp-Source: APXvYqz204bwQCfVj7LijKn7DnAxQP36R47gS1J2FUGlGpuQXfu7Nt6FgxEWmIi2nDEmEuazYRZnUw== X-Received: by 2002:a9d:459d:: with SMTP id x29mr23202522ote.39.1565751921503; Tue, 13 Aug 2019 20:05:21 -0700 (PDT) Original-Received: from floss ([2602:306:3707:da30:80b2:273b:9f29:480f]) by smtp.gmail.com with ESMTPSA id l15sm38298966otr.38.2019.08.13.20.05.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2019 20:05:20 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::333 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:239353 Archived-At: --=-=-= Content-Type: text/plain This patch implements 'isearch-yank-until-char', a new yank command in isearch. While in an isearch, one types C-M-c to yank into the search string everything from point up to (but not including) the next instance of a specified character. It prompts for the character. For example, assume point is on the "m" after the "#" mark below: [example from a recent macro I wrote](#markdown-link-syntax) Start an isearch with C-s, then do C-M-c followed by ")". The search string is now "markdown-link-syntax". I have found this functionality very helpful in macros. If it's a useful contribution to Emacs, then I'll install it. I'll wait at least three days to get feedback, both about the feature itself and about the choice of M-C-c as the keybinding. If there's no response or no consensus, then I won't install it, as being conservative about isearch seems appropriate. Best regards, -Karl --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=patch-isearch-yank-until-char.txt Content-Description: Patch to implement isearch-yank-until-char [[[ 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. ]]] diff --git doc/emacs/search.texi doc/emacs/search.texi index 66af5d4016..2d1980b26e 100644 --- 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 M-s C-e @r{(Incremental search)} +@findex isearch-yank-line + Similarly, @kbd{C-M-c} (@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)} diff --git lisp/isearch.el lisp/isearch.el index 30f7fc7254..7d2f78f49d 100644 --- 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 everything until the specified character to 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 "\M-\C-c" '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 everything 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,16 @@ 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)) + (search-forward (char-to-string char)) + (forward-char -1) + (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." --=-=-=--