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: Thu, 15 Aug 2019 23:53:44 -0500 Message-ID: <87sgq1r9rb.fsf@red-bean.com> References: <87tvakfnv4.fsf@red-bean.com> <87lfvvjxjs.fsf@mail.linkov.net> Reply-To: Karl Fogel Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="132271"; 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: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 16 06:54:00 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 1hyUFU-000YFX-1w for ged-emacs-devel@m.gmane.org; Fri, 16 Aug 2019 06:54:00 +0200 Original-Received: from localhost ([::1]:49216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyUFS-0005rN-UG for ged-emacs-devel@m.gmane.org; Fri, 16 Aug 2019 00:53:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46783) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hyUFL-0005r1-V3 for emacs-devel@gnu.org; Fri, 16 Aug 2019 00:53:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hyUFJ-0005ly-Tu for emacs-devel@gnu.org; Fri, 16 Aug 2019 00:53:51 -0400 Original-Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]:41227) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hyUFI-0005kc-8X for emacs-devel@gnu.org; Fri, 16 Aug 2019 00:53:49 -0400 Original-Received: by mail-oi1-x22a.google.com with SMTP id g7so3928151oia.8 for ; Thu, 15 Aug 2019 21:53:47 -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=kO5uqwPs2zyv0d4MxBIdiwwoW+YfTJIlNcAzMmoSkfk=; b=Mx2nDnwRcprkUqmbmVk42ACzaxR9XfixgIU+Yk0H/eKkTkwsdgNPo1OGOnPDZnWlns B4ujJRwJhDd3Lk8JshQbJShvwF0cLT8fWTseNBAXNIV9n5coiTHD3QMEvPjkSrmSzN84 iqu1tARymVJlXtX798QyevbhGp0+kdrmlUrl4UKjQCjxlr2XccP91D4bbJIlQsOcDv+W 3lGjY4Y1c0C169olNhs55ZW5TRZHkC30pJxnkMQkteVlmCj9MEtWR6Ntxvc0/lbGLoGj SMPi0rXHuXlS5FPQs/Y+jSSDuVQFvap7O/RlRu3O0TBY6BymHNd5m0eOe1SgHOAfPYUt Sm/w== 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=kO5uqwPs2zyv0d4MxBIdiwwoW+YfTJIlNcAzMmoSkfk=; b=YA58BNL/3Rk+1hniPnmSmf5LBdCo3b2ZdPPVo4Z7o/9oAFZHO7kr/WF6xVI9Q68l4y uFZWuYNk9ljqEE0+cpItiYJZ2mClY86OnCnzQ28OYD84ohxu++FK9LehQC/EX3K2Nd2Q 8s6TcR5/vVmjoeaXfkW3hMf2yF5xY9wtopJf+gFsFM8um/k47UPN8F748YyNTMd02BDb WIk3iZuUDzN0qlUN6gnHFLAoVbuOJJED1iBFzXfrOMZKZH6QGeeL1BrHbq9gfWNxDuM8 kvvEFWmFyj6rhrXcjtkfcVziKwjztEcuZxrnrjnLapbUjwd+oLkMSJca8YBsDweocl4i luEQ== X-Gm-Message-State: APjAAAUsR+Jnf081kTNkGrMDkpqFADibR5mD8CfoCA8QgjnLPhekZlT8 /U6O5M4Od6Y2JVwto+XTNVtXQT6o X-Google-Smtp-Source: APXvYqwnwB93B95PNHcUrBT+v7/iZOdSF+mo6/ISqUxD/PDE2PkyqBz8R0hOY/NqQ02rA5+u7d0u+w== X-Received: by 2002:aca:57ce:: with SMTP id l197mr3978043oib.121.1565931226514; Thu, 15 Aug 2019 21:53:46 -0700 (PDT) Original-Received: from floss ([2602:306:3707:da30:684e:72dc:19ec:6d53]) by smtp.gmail.com with ESMTPSA id v5sm1785673otk.64.2019.08.15.21.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2019 21:53:45 -0700 (PDT) In-Reply-To: <87lfvvjxjs.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 14 Aug 2019 23:34:47 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::22a 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:239390 Archived-At: On 14 Aug 2019, Juri Linkov wrote: >Globally 'C-M-c' is bound to 'exit-recursive-edit', so the question is >does anyone want 'C-M-c' to quit isearch and execute 'exit-recursive-edit'? >I never used 'C-M-c' to quit isearch. Neither have I. >One problem is that typing 'C-s C-M-c ' at the end of the buffer >raises the error: > > Debugger entered--Lisp error: (search-failed " ") > search-forward(" ") > isearch-yank-until-char(32) > funcall-interactively(isearch-yank-until-char 32) > call-interactively(isearch-yank-until-char nil nil) > command-execute(isearch-yank-until-char) > >and leaves isearch in a broken state. Should your new command >catch this error? It could. I'm not sure exacly what to do with the error, though. The new version below displays a brief message and then returns to the isearch prompt: (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)) (condition-case nil (progn (search-forward (char-to-string char)) (forward-char -1)) (search-failed (message "`%c' not found" char) (sit-for 2))) (point))))) This feels klugey, but I'm not sure what a better way is. Do you have any ideas? I also tried raising an error -- i.e., substitute `message' above with `error' and get rid of the `(sit-for 2)' -- but the problem with that is that it *never* returns to the isearch prompt, even though in either case isearch is still active and one could continue adding to the search string. Best regards, -Karl