all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#58423: 29.0.50; Weird behavior of string-edit
@ 2022-10-10 22:33 Jean Louis
  2022-10-11  0:07 ` Stefan Kangas
  2022-10-11  0:36 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 12+ messages in thread
From: Jean Louis @ 2022-10-10 22:33 UTC (permalink / raw)
  To: 58423


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/





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-10 22:33 bug#58423: 29.0.50; Weird behavior of string-edit Jean Louis
@ 2022-10-11  0:07 ` Stefan Kangas
  2022-10-11 14:10   ` Jean Louis
  2022-10-11  0:36 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 12+ messages in thread
From: Stefan Kangas @ 2022-10-11  0:07 UTC (permalink / raw)
  To: Jean Louis, 58423

Jean Louis <bugs@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?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-10 22:33 bug#58423: 29.0.50; Weird behavior of string-edit Jean Louis
  2022-10-11  0:07 ` Stefan Kangas
@ 2022-10-11  0:36 ` Lars Ingebrigtsen
  2022-10-11 10:40   ` Phil Sainty
  2022-10-11 14:12   ` Jean Louis
  1 sibling, 2 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2022-10-11  0:36 UTC (permalink / raw)
  To: Jean Louis; +Cc: 58423

Jean Louis <bugs@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11  0:36 ` Lars Ingebrigtsen
@ 2022-10-11 10:40   ` Phil Sainty
  2022-10-11 11:00     ` Lars Ingebrigtsen
  2022-10-11 14:12   ` Jean Louis
  1 sibling, 1 reply; 12+ messages in thread
From: Phil Sainty @ 2022-10-11 10:40 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jean Louis, 58423

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).






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11 10:40   ` Phil Sainty
@ 2022-10-11 11:00     ` Lars Ingebrigtsen
  2022-10-11 12:11       ` Phil Sainty
  2022-10-11 14:17       ` Jean Louis
  0 siblings, 2 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2022-10-11 11:00 UTC (permalink / raw)
  To: Phil Sainty; +Cc: Jean Louis, 58423

Phil Sainty <psainty@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'.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11 11:00     ` Lars Ingebrigtsen
@ 2022-10-11 12:11       ` Phil Sainty
  2022-10-11 14:17       ` Jean Louis
  1 sibling, 0 replies; 12+ messages in thread
From: Phil Sainty @ 2022-10-11 12:11 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Jean Louis, 58423

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.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11  0:07 ` Stefan Kangas
@ 2022-10-11 14:10   ` Jean Louis
  0 siblings, 0 replies; 12+ messages in thread
From: Jean Louis @ 2022-10-11 14:10 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 58423

* Stefan Kangas <stefankangas@gmail.com> [2022-10-11 03:09]:
> Jean Louis <bugs@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/





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11  0:36 ` Lars Ingebrigtsen
  2022-10-11 10:40   ` Phil Sainty
@ 2022-10-11 14:12   ` Jean Louis
  2022-10-11 14:14     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 12+ messages in thread
From: Jean Louis @ 2022-10-11 14:12 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 58423

* Lars Ingebrigtsen <larsi@gnus.org> [2022-10-11 03:36]:
> Jean Louis <bugs@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/





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11 14:12   ` Jean Louis
@ 2022-10-11 14:14     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2022-10-11 14:14 UTC (permalink / raw)
  To: Jean Louis; +Cc: 58423

Jean Louis <bugs@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.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11 11:00     ` Lars Ingebrigtsen
  2022-10-11 12:11       ` Phil Sainty
@ 2022-10-11 14:17       ` Jean Louis
  2022-10-11 19:34         ` Juri Linkov
  1 sibling, 1 reply; 12+ messages in thread
From: Jean Louis @ 2022-10-11 14:17 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Phil Sainty, 58423

* Lars Ingebrigtsen <larsi@gnus.org> [2022-10-11 15:29]:
> Phil Sainty <psainty@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/





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11 14:17       ` Jean Louis
@ 2022-10-11 19:34         ` Juri Linkov
  2022-10-11 19:37           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2022-10-11 19:34 UTC (permalink / raw)
  To: Jean Louis; +Cc: Phil Sainty, Lars Ingebrigtsen, 58423

>> > 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'.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#58423: 29.0.50; Weird behavior of string-edit
  2022-10-11 19:34         ` Juri Linkov
@ 2022-10-11 19:37           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2022-10-11 19:37 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Phil Sainty, Jean Louis, 58423

Juri Linkov <juri@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-10-11 19:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 22:33 bug#58423: 29.0.50; Weird behavior of string-edit Jean Louis
2022-10-11  0:07 ` Stefan Kangas
2022-10-11 14:10   ` Jean Louis
2022-10-11  0:36 ` Lars Ingebrigtsen
2022-10-11 10:40   ` Phil Sainty
2022-10-11 11:00     ` Lars Ingebrigtsen
2022-10-11 12:11       ` Phil Sainty
2022-10-11 14:17       ` Jean Louis
2022-10-11 19:34         ` Juri Linkov
2022-10-11 19:37           ` Lars Ingebrigtsen
2022-10-11 14:12   ` Jean Louis
2022-10-11 14:14     ` Lars Ingebrigtsen

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.