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: Wed, 10 Oct 2018 22:49:19 +0200 Message-ID: <86pnwh4je8.fsf@protected.rcdrun.com> 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 1539204554 21911 195.159.176.226 (10 Oct 2018 20:49:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 10 Oct 2018 20:49:14 +0000 (UTC) User-Agent: mu4e 1.0; emacs 27.0.50 To: 33007@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 10 22:49:10 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 1gALPo-0005Xh-UV for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Oct 2018 22:49:09 +0200 Original-Received: from localhost ([::1]:59112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gALRv-0003s1-JX for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Oct 2018 16:51:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gALRi-0003q1-75 for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2018 16:51:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gALRe-0003bS-NK for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2018 16:51:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39659) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gALRe-0003bL-HS for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2018 16:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gALRe-0003G9-DJ for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2018 16:51: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: Wed, 10 Oct 2018 20:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33007 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.153920461812479 (code B ref -1); Wed, 10 Oct 2018 20:51:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Oct 2018 20:50:18 +0000 Original-Received: from localhost ([127.0.0.1]:43917 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gALQw-0003FC-8e for submit@debbugs.gnu.org; Wed, 10 Oct 2018 16:50:18 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gALQu-0003Ez-1I for submit@debbugs.gnu.org; Wed, 10 Oct 2018 16:50:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gALQm-0003D6-VS for submit@debbugs.gnu.org; Wed, 10 Oct 2018 16:50:10 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:46843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gALQm-0003Ct-Oq for submit@debbugs.gnu.org; Wed, 10 Oct 2018 16:50:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gALQl-0003FX-Ue for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2018 16:50:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gALQi-0003AR-Jm for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2018 16:50:07 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:60827) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gALQi-0002oF-BF for bug-gnu-emacs@gnu.org; Wed, 10 Oct 2018 16:50:04 -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 13:49:22 -0700 id 00000000000E78F1.000000005BBE65D2.00000914 Original-Received: from localhost (localhost [127.0.0.1]) (uid 1001) by protected.rcdrun.com with local id 00000000000C1222.000000005BBE65CF.00005B13; Wed, 10 Oct 2018 22:49:19 +0200 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:151085 Archived-At: 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