From: Juri Linkov <juri@linkov.net>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Michael Heerdegen <michael_heerdegen@web.de>,
33007@debbugs.gnu.org, Jean Louis <bugs@gnu.support>
Subject: bug#33007: 27.0.50; Proposal for function to edit and return string
Date: Sun, 08 May 2022 21:22:47 +0300 [thread overview]
Message-ID: <86ee13j348.fsf@mail.linkov.net> (raw)
In-Reply-To: <87fslxpl29.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 28 Apr 2022 12:19:10 +0200")
[-- Attachment #1: Type: text/plain, Size: 727 bytes --]
>> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: read-string-from-buffer.patch --]
[-- Type: text/x-diff, Size: 1285 bytes --]
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))))
next prev parent reply other threads:[~2022-05-08 18:22 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 20:49 bug#33007: 27.0.50; Proposal for function to edit and return string Jean Louis
2018-10-11 2:36 ` Eli Zaretskii
2018-10-11 6:33 ` Jean Louis
2018-10-11 13:31 ` Michael Heerdegen
2018-10-11 13:40 ` Jean Louis
2018-10-11 14:24 ` Eli Zaretskii
2018-10-11 20:20 ` Michael Heerdegen
2018-10-11 21:23 ` Drew Adams
2018-10-12 4:26 ` Eli Zaretskii
2018-10-12 11:26 ` Michael Heerdegen
2018-10-12 12:41 ` Eli Zaretskii
2022-04-24 13:15 ` Lars Ingebrigtsen
2022-04-25 3:00 ` Michael Heerdegen
2022-04-25 7:50 ` Lars Ingebrigtsen
2022-04-25 15:42 ` Juri Linkov
2022-04-25 22:26 ` Michael Heerdegen
2022-04-26 7:23 ` Juri Linkov
2022-04-26 9:56 ` Lars Ingebrigtsen
2022-04-26 15:36 ` Juri Linkov
2022-04-27 12:09 ` Lars Ingebrigtsen
2022-04-26 9:55 ` Lars Ingebrigtsen
2022-04-26 15:39 ` Juri Linkov
2022-04-27 12:10 ` Lars Ingebrigtsen
2022-04-27 16:44 ` Juri Linkov
2022-04-27 17:05 ` Lars Ingebrigtsen
2022-04-28 7:32 ` Juri Linkov
2022-04-28 10:19 ` Lars Ingebrigtsen
2022-05-08 18:22 ` Juri Linkov [this message]
2022-05-09 9:49 ` Lars Ingebrigtsen
2022-05-09 18:52 ` Juri Linkov
2022-05-10 1:53 ` Lars Ingebrigtsen
2022-04-25 22:46 ` Michael Heerdegen
2022-04-26 9:58 ` Lars Ingebrigtsen
2018-10-11 13:55 ` Eli Zaretskii
2018-10-11 14:01 ` Michael Heerdegen
2018-10-11 14:08 ` Jean Louis
2018-10-11 14:16 ` Michael Heerdegen
2018-10-11 14:27 ` Eli Zaretskii
2018-10-11 14:36 ` Jean Louis
[not found] ` <<87lg74zk2k.fsf@web.de>
[not found] ` <<834ldsy31m.fsf@gnu.org>
2018-10-11 14:41 ` Drew Adams
2018-10-11 16:40 ` Eric Abrahamsen
2018-10-15 20:34 ` Juri Linkov
2018-10-15 22:07 ` Drew Adams
2018-10-16 22:12 ` Juri Linkov
2018-10-16 23:05 ` Drew Adams
2018-10-17 15:39 ` Michael Heerdegen
[not found] <<86pnwh4je8.fsf@protected.rcdrun.com>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86ee13j348.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=33007@debbugs.gnu.org \
--cc=bugs@gnu.support \
--cc=larsi@gnus.org \
--cc=michael_heerdegen@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.