From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Must prevent switching from recursive edit buffers Date: Sat, 21 Dec 2024 20:38:20 +0300 Message-ID: References: <2756a07624cab7ceb1c68dd24e671ef7.support1@rcdrun.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2091"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.12 (2023-09-09) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 21 18:39:00 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tP3RM-0000Pi-TP for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 21 Dec 2024 18:39:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tP3Qv-0003x6-Fl; Sat, 21 Dec 2024 12:38:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tP3Qt-0003ww-Rg for help-gnu-emacs@gnu.org; Sat, 21 Dec 2024 12:38:31 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tP3Qr-0002JT-J4 for help-gnu-emacs@gnu.org; Sat, 21 Dec 2024 12:38:31 -0500 Original-Received: from localhost ([::ffff:41.75.184.59]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001C243.000000006766FD13.00102AE4; Sat, 21 Dec 2024 10:38:26 -0700 Mail-Followup-To: Stefan Monnier , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148908 Archived-At: * Stefan Monnier [2024-12-21 18:24]: > > That is some mystery. Those recursive-edit buffers show as > > > > [[[[[(Mail WK Fill)]]]]] > > > > but I cannot know in the list of buffer and CANNOT SEE to what buffers > > those [[[[]]]] belogns. > > Hmm... currently I think that Emacs's code does not record a clear > association between a recursive edit and "the buffer to which it > belongs" (arguably even this concept is ill-defined, although in > practice it is probably true that there is almost always a buffer with > which we can associate the recursive edit). > > Maybe we could start by implementing a command which shows a list of > current recursive edits by walking the backtrace and trying to guess > which "kind" of recursive edit it is and to which buffer is > "belongs". That is missing, thanks for recognizing the lack of logic. > Kinds would be things like `minibuffer`, `debugger`, `edebug`, > `query-replace`, ... But in my work they have always names. My recursive buffer opens full screen like any other. I understand someone or you, made similar function, but I don't like it, so I use this function below. (defun read-from-buffer (&optional value buffer-name mode title keymap place highlight-list minor-modes input-method) "Return string after editing it in buffer." (let* ((this-buffer (buffer-name)) (title (or title "")) (value (or value "")) (new-value value) (point (cond ((numberp place) place) ((listp place) (cdr (assoc "place" place))))) (table (when (listp place) (cdr (assoc "table" place)))) (column (when (listp place) (cdr (assoc "column" place)))) (table-id (when (listp place) (cdr (assoc "table-id" place)))) (buffer-name (or buffer-name "*RCD String Editing*")) (buffer-name (concat buffer-name " 🗒️")) ;; (my-buffer-kill-hook kill-buffer-hook) (read-buffer (get-buffer-create buffer-name))) (with-current-buffer read-buffer (switch-to-buffer read-buffer) (erase-buffer) (cond (mode (if (fboundp mode) (funcall mode) (rcd-message "You need `%s' mode" (symbol-name mode)))) (t (text-mode))) (setq rcd-db-current-table table) (setq rcd-db-current-column column) (setq rcd-db-current-table-id table-id) (local-set-key (kbd "") 'exit-recursive-edit) (local-set-key (kbd "C-c A") 'abort-recursive-edit) ;; total mess ;; (setq-local kill-buffer-hook (append kill-buffer-hook ;; (list ;; (lambda () ;; (setq-local kill-buffer-hook my-buffer-kill-hook) ;; (kill-buffer read-buffer) ;; (cond ((> (recursion-depth) 0) (exit-recursive-edit))))))) (when keymap (use-local-map keymap)) (when input-method (set-input-method input-method)) (when rcd-word-processing (rcd-word-processing)) (setq header-line-format (format "%s ➜ Finish editing with or C-M-c or F8" title)) (if (stringp value) (insert value)) (rcd-highlight-list highlight-list) (goto-char (or point (point-min))) (rcd-speak "You may quit the buffer with Meta Control C") (message "When you're done editing press C-M-c or F8 to continue.") (setq eval-expression-debug-on-error nil) (while minor-modes (let ((minor-mode (pop minor-modes))) (if minor-mode (if (fboundp (intern minor-mode)) (funcall (intern minor-mode)) (rcd-message "You need `%s' minor mode" (symbol-name minor-mode)))))) (unwind-protect (recursive-edit) (if (get-buffer-window read-buffer) (progn (setq new-value (buffer-substring (point-min) (point-max))) (kill-buffer read-buffer)))) (setq eval-expression-debug-on-error t) (prog1 new-value (switch-to-buffer this-buffer))))) ;; TODO if mode is used, maybe it should not return propertized string > That would have to rely on ad-hoc rules, but that would give us some > experience from which we could hopefully design a better API which ELisp > packages which use `recursive-edit` can then use to provide that same > information more directly. My buffers open up in full window. Each of them has a name. They are immediately available in the buffer list. But I cannot know yet why, they also disappear, so I am left with [[[[]]]] and do not know to what it belongs. Then I go to the buffer list and I can start deleting buffers, but have no idea which one is in recursive-edit, so sometimes I get result: - I have deleted buffers, and recursive edits are also resolved; - sometimes I have deleted it and [[[[]]]] still remain on the modeline; and I have no idea why; And I am still confused, maybe I am wrong about it in general. -- Jean Louis