Subject: 27.0.50; Proposal for function to edit and return string

From: Jean Louis <[email-masked]>
Date: Wed, 10 Oct 2018 22:49:19 +0200

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