From: Jean Louis <bugs@gnu.support>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: 58423@debbugs.gnu.org
Subject: bug#58423: 29.0.50; Weird behavior of string-edit
Date: Tue, 11 Oct 2022 17:10:42 +0300 [thread overview]
Message-ID: <Y0V5YrgsPLWqtZzo@protected.localdomain> (raw)
In-Reply-To: <CADwFkmnerC3BcRpiRiBccfHOAPeV_jSyxMYFjeCEzVUwO+MaHQ@mail.gmail.com>
* 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/
next prev parent reply other threads:[~2022-10-11 14:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=Y0V5YrgsPLWqtZzo@protected.localdomain \
--to=bugs@gnu.support \
--cc=58423@debbugs.gnu.org \
--cc=stefankangas@gmail.com \
/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.