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.

Full log


View this message in rfc822 format

From: Jean Louis <bugs <at> gnu.support>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 58423 <at> debbugs.gnu.org
Subject: 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/




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

Previous Next


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