[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#58423: 29.0.50; Weird behavior of string-edit
From: |
Jean Louis |
Subject: |
bug#58423: 29.0.50; Weird behavior of string-edit |
Date: |
Tue, 11 Oct 2022 17:10:42 +0300 |
User-agent: |
Mutt/2.2.7+37 (a90f69b) (2022-09-02) |
* 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/
- bug#58423: 29.0.50; Weird behavior of string-edit, Jean Louis, 2022/10/10
- bug#58423: 29.0.50; Weird behavior of string-edit, Stefan Kangas, 2022/10/10
- bug#58423: 29.0.50; Weird behavior of string-edit,
Jean Louis <=
- bug#58423: 29.0.50; Weird behavior of string-edit, Lars Ingebrigtsen, 2022/10/10
- bug#58423: 29.0.50; Weird behavior of string-edit, Phil Sainty, 2022/10/11
- bug#58423: 29.0.50; Weird behavior of string-edit, Lars Ingebrigtsen, 2022/10/11
- bug#58423: 29.0.50; Weird behavior of string-edit, Phil Sainty, 2022/10/11
- bug#58423: 29.0.50; Weird behavior of string-edit, Jean Louis, 2022/10/11
- bug#58423: 29.0.50; Weird behavior of string-edit, Juri Linkov, 2022/10/11
- bug#58423: 29.0.50; Weird behavior of string-edit, Lars Ingebrigtsen, 2022/10/11
bug#58423: 29.0.50; Weird behavior of string-edit, Jean Louis, 2022/10/11