unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33007: 27.0.50; Proposal for function to edit and return string
@ 2018-10-10 20:49 Jean Louis
  2018-10-11  2:36 ` Eli Zaretskii
  0 siblings, 1 reply; 46+ messages in thread
From: Jean Louis @ 2018-10-10 20:49 UTC (permalink / raw)
  To: 33007


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





^ permalink raw reply	[flat|nested] 46+ messages in thread
[parent not found: <<86pnwh4je8.fsf@protected.rcdrun.com>]

end of thread, other threads:[~2022-05-10  1:53 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-10 20:49 bug#33007: 27.0.50; Proposal for function to edit and return string Jean Louis
2018-10-11  2:36 ` Eli Zaretskii
2018-10-11  6:33   ` Jean Louis
2018-10-11 13:31     ` Michael Heerdegen
2018-10-11 13:40       ` Jean Louis
2018-10-11 14:24       ` Eli Zaretskii
2018-10-11 20:20         ` Michael Heerdegen
2018-10-11 21:23           ` Drew Adams
2018-10-12  4:26           ` Eli Zaretskii
2018-10-12 11:26             ` Michael Heerdegen
2018-10-12 12:41               ` Eli Zaretskii
2022-04-24 13:15       ` Lars Ingebrigtsen
2022-04-25  3:00         ` Michael Heerdegen
2022-04-25  7:50           ` Lars Ingebrigtsen
2022-04-25 15:42             ` Juri Linkov
2022-04-25 22:26               ` Michael Heerdegen
2022-04-26  7:23                 ` Juri Linkov
2022-04-26  9:56                 ` Lars Ingebrigtsen
2022-04-26 15:36                   ` Juri Linkov
2022-04-27 12:09                     ` Lars Ingebrigtsen
2022-04-26  9:55               ` Lars Ingebrigtsen
2022-04-26 15:39                 ` Juri Linkov
2022-04-27 12:10                   ` Lars Ingebrigtsen
2022-04-27 16:44                     ` Juri Linkov
2022-04-27 17:05                       ` Lars Ingebrigtsen
2022-04-28  7:32                       ` Juri Linkov
2022-04-28 10:19                         ` Lars Ingebrigtsen
2022-05-08 18:22                           ` Juri Linkov
2022-05-09  9:49                             ` Lars Ingebrigtsen
2022-05-09 18:52                               ` Juri Linkov
2022-05-10  1:53                                 ` Lars Ingebrigtsen
2022-04-25 22:46         ` Michael Heerdegen
2022-04-26  9:58           ` Lars Ingebrigtsen
2018-10-11 13:55     ` Eli Zaretskii
2018-10-11 14:01       ` Michael Heerdegen
2018-10-11 14:08       ` Jean Louis
2018-10-11 14:16         ` Michael Heerdegen
2018-10-11 14:27         ` Eli Zaretskii
2018-10-11 14:36           ` Jean Louis
     [not found]     ` <<87lg74zk2k.fsf@web.de>
     [not found]       ` <<834ldsy31m.fsf@gnu.org>
2018-10-11 14:41         ` Drew Adams
2018-10-11 16:40           ` Eric Abrahamsen
2018-10-15 20:34           ` Juri Linkov
2018-10-15 22:07             ` Drew Adams
2018-10-16 22:12               ` Juri Linkov
2018-10-16 23:05                 ` Drew Adams
2018-10-17 15:39                   ` Michael Heerdegen
     [not found] <<86pnwh4je8.fsf@protected.rcdrun.com>

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).