GNU bug report logs - #58423
29.0.50; Weird behavior of string-edit

Previous Next

Package: emacs;

Reported by: Jean Louis <bugs <at> gnu.support>

Date: Mon, 10 Oct 2022 23:41:02 UTC

Severity: normal

Tags: notabug

Found in version 29.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58423 in the body.
You can then email your comments to 58423 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Mon, 10 Oct 2022 23:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jean Louis <bugs <at> gnu.support>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 10 Oct 2022 23:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 01:33:14 +0300
I don't think that this is right return value from:

(string-edit "" "" 'ignore)

to be this:

#("Type C-c C-c when you’ve finished editing" 5 12 (font-lock-face help-key-binding face help-key-binding))



In GNU Emacs 29.0.50 (build 7, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.17.6, Xaw3d scroll bars) of 2022-10-10 built on
 protected.rcdrun.com
Repository revision: ed436db1320339862fad5ac754a6ec42de06c766
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Parabola GNU/Linux-libre

Configured using:
 'configure --with-x-toolkit=lucid'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LANG: de_DE.UTF-8
  value of $XMODIFIERS: @im=exwm-xim
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util time-date subr-x mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils text-property-search
string-edit cl-loaddefs cl-lib rmc iso-transl tooltip eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
faces cus-face macroexp files window text-properties overlay sha1 md5
base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
xinput2 x multi-tty make-network-process emacs)

Memory information:
((conses 16 39607 7812)
 (symbols 48 5166 2)
 (strings 32 14340 2028)
 (string-bytes 1 404301)
 (vectors 16 10449)
 (vector-slots 8 159634 9905)
 (floats 8 24 24)
 (intervals 56 325 0)
 (buffers 1000 12))

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 00:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Jean Louis <bugs <at> gnu.support>, 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Mon, 10 Oct 2022 19:07:43 -0500
Jean Louis <bugs <at> gnu.support> writes:

> I don't think that this is right return value from:
>
> (string-edit "" "" 'ignore)
>
> to be this:
>
> #("Type C-c C-c when you’ve finished editing" 5 12 (font-lock-face help-key-binding face help-key-binding))

Do you have a use case where you care about the return value?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 00:37:02 GMT) Full text and rfc822 format available.

Message #11 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jean Louis <bugs <at> gnu.support>
Cc: 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 02:36:08 +0200
Jean Louis <bugs <at> gnu.support> writes:

> I don't think that this is right return value from:
>
> (string-edit "" "" 'ignore)
>
> to be this:
>
> #("Type C-c C-c when you’ve finished editing" 5 12 (font-lock-face help-key-binding face help-key-binding))

That function isn't defined as having any particular return value, so
that's as good a value as any.

Closing.




Added tag(s) notabug. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 11 Oct 2022 00:37:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 58423 <at> debbugs.gnu.org and Jean Louis <bugs <at> gnu.support> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 11 Oct 2022 00:37:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 10:41:01 GMT) Full text and rfc822 format available.

Message #18 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Jean Louis <bugs <at> gnu.support>, 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 23:40:16 +1300
On 2022-10-11 13:36, Lars Ingebrigtsen wrote:
> That function isn't defined as having any particular return value,
> so that's as good a value as any.

Is it really, though?

How about returning the edited string (or nil if aborted)?  Then it
would be possible to use `string-edit' as a method of interactively
obtaining a string value.

Surely that's a useful-and-therefore-better return value (which
can then be documented).





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 11:01:02 GMT) Full text and rfc822 format available.

Message #21 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: Jean Louis <bugs <at> gnu.support>, 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 13:00:33 +0200
Phil Sainty <psainty <at> orcon.net.nz> writes:

> How about returning the edited string (or nil if aborted)?  Then it
> would be possible to use `string-edit' as a method of interactively
> obtaining a string value.

That's `read-string-from-buffer'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 12:12:01 GMT) Full text and rfc822 format available.

Message #24 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Jean Louis <bugs <at> gnu.support>, 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Wed, 12 Oct 2022 01:11:50 +1300
On 2022-10-12 00:00, Lars Ingebrigtsen wrote:
> That's `read-string-from-buffer'.

Aha.  I was going to suggest mentioning that in the `string-edit'
docstring to make this easier to discover, but I see you've just
done exactly that, so I think it looks good now.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 14:14:02 GMT) Full text and rfc822 format available.

Message #27 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 17:10:42 +0300
* Stefan Kangas <stefankangas <at> gmail.com> [2022-10-11 03:09]:
> Jean Louis <bugs <at> gnu.support> writes:
> 
> > I don't think that this is right return value from:
> >
> > (string-edit "" "" 'ignore)
> >
> > to be this:
> >
> > #("Type C-c C-c when you’ve finished editing" 5 12 (font-lock-face help-key-binding face help-key-binding))
> 
> Do you have a use case where you care about the return value?

My case is heavy use case, that is what I do every day.

I was thinking to start using the Emacs built-in feature, but then I
see it misbehaves.

Heavy use case is for editing values from database. Just any
values. Here is the function that I use and this one returns the
string.

(defun read-from-buffer (&optional value buffer-name mode title keymap place highlight-list minor-modes input-method)
  "Edits string and returns it"
  (let ((this-buffer (buffer-name))
	(title (or title ""))
	(value (or value ""))
	(new-value value)
	(point (cond ((numberp place) place)
		     ((listp place) (cdr (assoc "place" place)))))
	(table (when (listp place) (cdr (assoc "table" place))))
	(column (when (listp place) (cdr (assoc "column" place))))
	(table-id (when (listp place) (cdr (assoc "table-id" place))))
	(_ (message "EDIT %s" place))
	(_ (message "%s" place))
	(read-buffer (if buffer-name
			 (generate-new-buffer buffer-name)
		       (generate-new-buffer "*edit-string*"))))
    (save-excursion
      (switch-to-buffer read-buffer)
      (erase-buffer)
      (set-buffer read-buffer)
      (if mode
	  (if (fboundp mode)
	      (funcall mode)
	    (rcd-message "You need `%s' mode" (symbol-name mode)))
	(text-mode))
      (while minor-modes
	(let ((minor-mode (pop minor-modes)))
	  (if minor-mode
	      (if (fboundp (intern minor-mode))
		  (funcall (intern minor-mode))
		(rcd-message "You need `%s' minor mode" (symbol-name minor-mode))))))
      (setq rcd-db-current-table table)
      (setq rcd-db-current-column column)
      (setq rcd-db-current-table-id table-id)
      ;; (local-set-key (kbd "C-c C-c") 'exit-recursive-edit)
      (local-set-key (kbd "<f8>") 'exit-recursive-edit)
      (when keymap
	(use-local-map keymap))
      (when input-method (set-input-method input-method))
      (setq header-line-format (format "%s ➜ Finish editing with or C-M-c or F8" title))
      (if (stringp value) (insert value))
      (goto-char (or point (point-min)))
      (message "When you're done editing press C-M-c or F8 to continue.")
      (setq eval-expression-debug-on-error nil)
      (unwind-protect
	  (recursive-edit)
	(if (get-buffer-window read-buffer)
	    (progn
	      (setq new-value (buffer-substring (point-min) (point-max)))
	      (kill-buffer read-buffer))))
      (setq eval-expression-debug-on-error t)
      (switch-to-buffer this-buffer)
      new-value))) ;; TODO if mode is used, maybe it should not return propertized string


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 14:14:02 GMT) Full text and rfc822 format available.

Message #30 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 17:12:40 +0300
* Lars Ingebrigtsen <larsi <at> gnus.org> [2022-10-11 03:36]:
> Jean Louis <bugs <at> gnu.support> writes:
> 
> > I don't think that this is right return value from:
> >
> > (string-edit "" "" 'ignore)
> >
> > to be this:
> >
> > #("Type C-c C-c when you’ve finished editing" 5 12 (font-lock-face help-key-binding face help-key-binding))
> 
> That function isn't defined as having any particular return value, so
> that's as good a value as any.
> 
> Closing.

I can just say "WOW" on that.

I understand that the fallback function is called and I like the
approach.

But from functions I expect return values.

If there is success than I would expect TRUE or something.

Best would be not to have special function to handle that, but to have
return value. See my function in previous email.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 14:15:01 GMT) Full text and rfc822 format available.

Message #33 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jean Louis <bugs <at> gnu.support>
Cc: 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 16:14:36 +0200
Jean Louis <bugs <at> gnu.support> writes:

> I understand that the fallback function is called and I like the
> approach.

It's not a fallback function -- it's a callback function.

> But from functions I expect return values.

Then your expectations are wrong -- many functions don't return anything
meaningful, but work by side effect only.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 14:19:02 GMT) Full text and rfc822 format available.

Message #36 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 17:17:47 +0300
* Lars Ingebrigtsen <larsi <at> gnus.org> [2022-10-11 15:29]:
> Phil Sainty <psainty <at> orcon.net.nz> writes:
> 
> > How about returning the edited string (or nil if aborted)?  Then it
> > would be possible to use `string-edit' as a method of interactively
> > obtaining a string value.
> 
> That's `read-string-from-buffer'.

Aha that one, thanks. 

(read-string-from-buffer "Enter text" "") ⇒ "OK here"

It is to consider, thanks. I like it full window.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 19:36:02 GMT) Full text and rfc822 format available.

Message #39 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Jean Louis <bugs <at> gnu.support>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 22:34:09 +0300
>> > How about returning the edited string (or nil if aborted)?  Then it
>> > would be possible to use `string-edit' as a method of interactively
>> > obtaining a string value.
>>
>> That's `read-string-from-buffer'.
>
> Aha that one, thanks.
>
> (read-string-from-buffer "Enter text" "") ⇒ "OK here"

I expected that typing immediately 'C-c C-c' will return an empty string,
but it returned the prompt.  A bug?

> It is to consider, thanks. I like it full window.

It's possible to customize to full window by 'display-buffer-alist'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58423; Package emacs. (Tue, 11 Oct 2022 19:38:01 GMT) Full text and rfc822 format available.

Message #42 received at 58423 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: Phil Sainty <psainty <at> orcon.net.nz>, Jean Louis <bugs <at> gnu.support>,
 58423 <at> debbugs.gnu.org
Subject: Re: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 21:37:14 +0200
Juri Linkov <juri <at> linkov.net> writes:

>> (read-string-from-buffer "Enter text" "") ⇒ "OK here"
>
> I expected that typing immediately 'C-c C-c' will return an empty string,
> but it returned the prompt.  A bug?

Yup.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 Nov 2022 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 274 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.