GNU bug report logs -
#33007
27.0.50; Proposal for function to edit and return string
Previous Next
Reported by: Jean Louis <bugs <at> gnu.support>
Date: Wed, 10 Oct 2018 20:51:02 UTC
Severity: wishlist
Found in version 27.0.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
I would like to propose function for GNU Emacs so that there is
function to edit and return the string.
It would be equivalent to read-from-minibuffer only that we shall have
function to edit in the whole buffer, not just in one line in mini
buffer.
Sadly I don't know how to make it.
Here are my two attempts:
(defun rcd-edit-value (value)
(let ((file (make-temp-file "rcd-db-" nil ".txt" value)))
(find-file file)
(string-from-file)))
(defun string-from-file (file)
"Return file content."
(with-temp-buffer
(insert-file-contents file)
(buffer-string)))
(setq got-it (rcd-edit-value "something"))
but this one is not working as (find-file file) does not wait, and I get
"something" back from file.
This below is my other attempt which looks more logical and could end
with C-c C-c but I am failing to get the value given back.
(defun buffer-out ()
(interactive)
(let ((buffer (current-buffer))
(value (buffer-string)))
(kill-buffer buffer)))
;; (defun buffer-string-out ()
;; (interactive)
;; (buffer-string))
(defun edit-string (string)
(interactive)
(let ((buffer "*edit-string*"))
(get-buffer-create buffer)
(switch-to-buffer buffer)
(set-buffer buffer)
(let ((inhibit-read-only nil))
(insert string)
(fundamental-mode)
(local-set-key (kbd "C-c C-c") 'buffer-out))))
In my opinion such function shall exist in Emacs by standard, so that
user is able to quickly edit string in a temporary buffer or temporary
file or both, and that value of the buffer is returned back.
Several people asked me why I would do that. Some variables requires
editing, and variables could be as big as Org file, and they could come
from a database.
Then I could edit field values from PostgreSQL database and construct
other small helpful programs.
Jean
This bug report was last modified 3 years and 68 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.