From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.bugs Subject: bug#33007: 27.0.50; Proposal for function to edit and return string Date: Thu, 11 Oct 2018 08:33:21 +0200 Message-ID: <20181011063321.GD27672@protected.rcdrun.com> References: <86pnwh4je8.fsf@protected.rcdrun.com> <83bm81xl84.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1539239525 24884 195.159.176.226 (11 Oct 2018 06:32:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 11 Oct 2018 06:32:05 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 33007@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 11 08:32:01 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAUVt-0006M4-Fd for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Oct 2018 08:32:01 +0200 Original-Received: from localhost ([::1]:60778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAUXz-0007So-VQ for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Oct 2018 02:34:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAUXt-0007Sj-VQ for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2018 02:34:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAUXq-0000Hv-Iz for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2018 02:34:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39828) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gAUXq-0000Hj-D1 for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2018 02:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gAUXq-0004ko-8n for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2018 02:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jean Louis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Oct 2018 06:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33007 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33007-submit@debbugs.gnu.org id=B33007.153923961118234 (code B ref 33007); Thu, 11 Oct 2018 06:34:02 +0000 Original-Received: (at 33007) by debbugs.gnu.org; 11 Oct 2018 06:33:31 +0000 Original-Received: from localhost ([127.0.0.1]:44086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAUXL-0004k2-7P for submit@debbugs.gnu.org; Thu, 11 Oct 2018 02:33:31 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:55573) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAUXJ-0004jm-Gr for 33007@debbugs.gnu.org; Thu, 11 Oct 2018 02:33:29 -0400 Original-Received: from protected.rcdrun.com ([::ffff:31.223.149.38]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA; Wed, 10 Oct 2018 23:33:23 -0700 id 00000000000E78F1.000000005BBEEEB3.00001CE4 Original-Received: from localhost (localhost [127.0.0.1]) (uid 1001) by protected.rcdrun.com with local id 00000000000C2229.000000005BBEEEB1.0000746D; Thu, 11 Oct 2018 08:33:21 +0200 Content-Disposition: inline In-Reply-To: <83bm81xl84.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:151095 Archived-At: On Thu, Oct 11, 2018 at 05:36:59AM +0300, Eli Zaretskii wrote: > > From: Jean Louis > > 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. > > We already have read-string, I think it does what you want. It reads from mini buffer, it does not open standard buffer where one could change modes and have editing capabilities, preview, insert from other files, etc. I have found solution for me. And I think something like that shall be included in emacs. Why? We have read-from-minibuffer. Logically there shall be read-from-buffer too. Isn't it? I am using this one below now but it would be nice to have it as fully fledged with options etc. professional built-in function. I have website revision system written in LISP that invokes Emacs to edit PostgreSQL variables, including LISP variables. Such contain markup, notes, description, bodies of text that cannot fit into read-string function and where I need to preview the file, work with it, until it is published. Some page are even in Org mode, so I would need to see how they look like before I let it be fed into the database again. At the moment I tried doing the same from within Emacs, I have spent hours trying to find something like read-from-buffer as I was convinced it exists there. That is why I am proposing standardized function to read-from-buffer with nice options as built in function. And I will appreciate any improvements to the below function. Jean Something like this below shall become read-from-buffer ;;; edited from https://raw.githubusercontent.com/deestan/emacs/master/emacs-goodies-el/miniedit.el (defun edit-string (value) "Edits string and returns it" (let ((this-buffer (buffer-name)) (new-value value) (buffy "*edit-string*")) (save-excursion (switch-to-buffer buffy) (set-buffer buffy) (text-mode) (local-set-key (kbd "C-c C-c") 'exit-recursive-edit) (if (stringp value) (insert value)) (message "When you're done editing press C-c C-c or C-M-c to continue.") (unwind-protect (recursive-edit) (if (get-buffer-window buffy) (progn (setq new-value (buffer-substring (point-min) (point-max))) (kill-buffer buffy)))) (switch-to-buffer this-buffer) new-value)))