From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#33007: 27.0.50; Proposal for function to edit and return string Date: Sun, 08 May 2022 21:22:47 +0300 Organization: LINKOV.NET Message-ID: <86ee13j348.fsf@mail.linkov.net> References: <86pnwh4je8.fsf@protected.rcdrun.com> <83bm81xl84.fsf@gnu.org> <20181011063321.GD27672@protected.rcdrun.com> <87lg74zk2k.fsf@web.de> <87v8uybp1c.fsf@gnus.org> <871qxlj293.fsf@web.de> <875ymx7ga6.fsf@gnus.org> <86pml5gp6m.fsf@mail.linkov.net> <87a6c8jhjb.fsf@gnus.org> <86czh3vp4g.fsf@mail.linkov.net> <87sfpyd8wu.fsf@gnus.org> <86wnfascft.fsf@mail.linkov.net> <86r15hvelj.fsf@mail.linkov.net> <87fslxpl29.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26523"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: Michael Heerdegen , 33007@debbugs.gnu.org, Jean Louis To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 08 20:26:11 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nnlbf-0006iM-Eg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 May 2022 20:26:11 +0200 Original-Received: from localhost ([::1]:51624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnlbe-0008Ky-39 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 May 2022 14:26:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnlbW-0008KS-Mg for bug-gnu-emacs@gnu.org; Sun, 08 May 2022 14:26:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nnlbW-0003Dv-De for bug-gnu-emacs@gnu.org; Sun, 08 May 2022 14:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nnlbW-0005yt-8V for bug-gnu-emacs@gnu.org; Sun, 08 May 2022 14:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 May 2022 18:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33007 X-GNU-PR-Package: emacs Original-Received: via spool by 33007-submit@debbugs.gnu.org id=B33007.165203431822933 (code B ref 33007); Sun, 08 May 2022 18:26:02 +0000 Original-Received: (at 33007) by debbugs.gnu.org; 8 May 2022 18:25:18 +0000 Original-Received: from localhost ([127.0.0.1]:55216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnlan-0005xp-Nk for submit@debbugs.gnu.org; Sun, 08 May 2022 14:25:17 -0400 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:58753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnlam-0005xK-2d for 33007@debbugs.gnu.org; Sun, 08 May 2022 14:25:16 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id BDC12240004; Sun, 8 May 2022 18:25:07 +0000 (UTC) In-Reply-To: <87fslxpl29.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 28 Apr 2022 12:19:10 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:231680 Archived-At: --=-=-= Content-Type: text/plain >> Maybe a separate bug report is needed? Because it seems that >> the order of processing these parameters should be rather like this: >> >> 1. first set window-height with fit-window-to-buffer; >> 2. then check if the constraint of window-min-height is fulfilled, >> and shrink too high window. >> >> Then 'string-edit' will insert the initial string, and >> 'fit-window-to-buffer' will fit the window. If the window height >> is less than 10 lines, it will enlarge to 10 lines. But in case of >> too many lines, the window height should not be more than >> half of the original window. > > Yup; sounds like a separate bug report is warranted. As was found in bug#55169, this is already possible to do with a lambda: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=read-string-from-buffer.patch diff --git a/lisp/textmodes/string-edit.el b/lisp/textmodes/string-edit.el index ab0b3b3bd7..d3f614ca94 100644 --- a/lisp/textmodes/string-edit.el +++ b/lisp/textmodes/string-edit.el @@ -47,7 +47,10 @@ string-edit PROMPT will be inserted at the start of the buffer, but won't be included in the resulting string. If PROMPT is nil, no help text will be inserted." - (pop-to-buffer-same-window (generate-new-buffer "*edit string*")) + (pop-to-buffer (generate-new-buffer "*edit string*") + '(display-buffer-below-selected + (window-height . (lambda (window) + (fit-window-to-buffer window nil 10))))) (when prompt (let ((inhibit-read-only t)) (insert prompt) @@ -113,14 +116,14 @@ string-edit-done (goto-char (prop-match-beginning match))) (let ((string (buffer-substring (point) (point-max))) (callback string-edit--success-callback)) - (kill-buffer (current-buffer)) + (quit-window 'kill) (funcall callback string))) (defun string-edit-abort () "Abort editing the current string." (interactive) (let ((callback string-edit--abort-callback)) - (kill-buffer (current-buffer)) + (quit-window 'kill) (when callback (funcall callback)))) --=-=-=--