From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.bugs Subject: bug#18183: 24.3; table-fixed-width-mode fails with kill/yank Date: Tue, 8 Dec 2020 02:18:02 -0500 Message-ID: <20201208071802.uzm4q6vtzpzmcbj2@E15-2016.optimum.net> References: <53DE7C34.6030304@gmx.com> <87y2idizbd.fsf@gnus.org> <20201206090648.n23pfcopzkalkwqb@E15-2016.optimum.net> <877dpvc8hm.fsf@gnus.org> <20201206182023.jabgkssgn2g4okjt@E15-2016.optimum.net> <871rg1k9hr.fsf@gnus.org> <87wnxtiubi.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17774"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: NeoMutt/20180716 Cc: 18183@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 08 08:20:07 2020 Return-path: Envelope-to: geb-bug-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 1kmXI7-0004Ud-GN for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 08 Dec 2020 08:20:07 +0100 Original-Received: from localhost ([::1]:60298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmXI5-0004Mz-Bb for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 08 Dec 2020 02:20:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmXH4-0004Mp-Bb for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2020 02:19:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44830) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmXH4-0008KE-42 for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2020 02:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kmXH3-0002ai-W3 for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2020 02:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Boruch Baum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Dec 2020 07:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18183 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 18183-submit@debbugs.gnu.org id=B18183.16074118979899 (code B ref 18183); Tue, 08 Dec 2020 07:19:01 +0000 Original-Received: (at 18183) by debbugs.gnu.org; 8 Dec 2020 07:18:17 +0000 Original-Received: from localhost ([127.0.0.1]:56376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kmXGK-0002Zb-Fv for submit@debbugs.gnu.org; Tue, 08 Dec 2020 02:18:16 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:37993) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kmXGF-0002ZF-8n for 18183@debbugs.gnu.org; Tue, 08 Dec 2020 02:18:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1607411885; bh=EOv9+TkXi1Por/Ti5NMbY0TS9Ry1Lm8KBgnnMXm8ieU=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=BKr4t+MhwGxy0ZXAw6c2GVx0N2TLWnz7Jr/uZe1fahm05Ss2ygO0+eWXOw5JPWSWG ytwpWUjeHC95yObRWOBMdiVnabutOqyz35qBzdBjlkMvIXTsWJ8Q1QOpLkDdzJLYSx kL5E/XSWNWkHGXmNVtOTIE11SDSYBvO+loGtR2j8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from E15-2016.optimum.net ([70.19.86.82]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N63RQ-1k6uzU31rs-016OtH; Tue, 08 Dec 2020 08:18:05 +0100 Content-Disposition: inline In-Reply-To: <87wnxtiubi.fsf@gnus.org> X-Provags-ID: V03:K1:YCc+GK2SJ/Hu5FzUJfPb50R1HLbpiY1vVUYlki6fRvSrwzVojwA 7gIllWFl3mm2IAq2xdPfJFH1IeQd8IPZueMfw26vPLmB5B+baAUxl3ooSekb3SMMLOQHq6/ QyvpIiSH2y3tHkfZB+1yPzlfiPAPXRxaSBNkgibchig8+MS22wbJZNCzODMWczxcCQi5YdL 0gKSkK1J62fQWfWhihChA== X-UI-Out-Filterresults: notjunk:1;V03:K0:FXR3KI9BYK8=:q7lCGkpMEBjPsU1Xh90L/W uGmjO4nVNJOxy6Qw7ZN2QpflgPAxoMjLSxFEMZpaX9iTqOj+KI7pOokyq7Xt5wpowq6VKLBgD t2lDCJHHa7UR0yKRoBTkA20JCpYDgeLPe2urs5pGwVy7br8R1V1YjNqOy7P2aZYjMtts9bppF gKbS5VIvu01VyLGUALB7Al8ZQFjxy6OZE2RtgOBDZWY2nfBM6gzHom2/FPKwybyzhcLs8ezIA A1jiW46SSlTDGVweAKgAfZHCTemx4syBdUtW5k7rqeYXn+Uu92ljhUtsABdsBm1UOWymKCZRA ZwfztmOCjzk8nfOKsMZXhNQTUnHBOuywI6rtKpsxIV62Di4brSeyurv/gutMzNs6iYD8kjg5V AiDDyRGjc5bKLTuTbnaghXBLo0qV1JjhLO+r7QACfs/WJ+v215at7SIW8dWAjEfUfZBnYjAos OtjB7zsiUDD17iDg5qC6vFKXvQbzZLJxCrz+LOIJsyUIK9Dljy8Qdxj/VujHVUnhOvhHbdZaW AyNhLMgf8sL+1yxKYJX7y4lCUt/+DPFmk7w85kyVRPo7VNoL2L1SLpenPpT1m4XAb3g1TJ6mX iyXkNWIKv+vy3IsBfu7S9YaH/BoLRdedF0m+N4vqB/kGuiZvNtqzs9d06kl1hsNhNB1+m8JRG AR+1afgdnZsM2tlRUBdRT+A02DZn3i9KXmM2dEJ8/TiAtkkMTy55AzmZqito66EVctmhwHDOa mnxqfBp0se1cJXbyenrtpTdmTD7b7CbpKJysgoy5puIPqSUGbHKSV+o4LzHoO6TEWenWalNL X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:195311 Archived-At: Hi Lars. I've been doing some more work on the bug and have a solution for the secondary issue found, the one that I marked previously as 'tangent'. In that related bug, aborting from a table.el edit sets POINT at the beginning of the table instead of where it was upon entry to the edit session. The solution was simply to save and restore point. The saving is done in function org-src--edit-element and the restore is performed in function org-edit-src-abort. Here are the modified functions with the two additional lines marked with arrows ; <------ (defun org-src--edit-element (datum name &optional initialize write-back contents remote) "Edit DATUM contents in a dedicated buffer NAME. INITIALIZE is a function to call upon creating the buffer. When WRITE-BACK is non-nil, assume contents will replace original region. Moreover, if it is a function, apply it in the edit buffer, from point min, before returning the contents. When CONTENTS is non-nil, display them in the edit buffer. Otherwise, show DATUM contents as specified by `org-src--contents-area'. When REMOTE is non-nil, do not try to preserve point or mark when moving from the edit area to the source. Leave point in edit buffer." (setq org-src--saved-temp-window-config (current-window-configuration)) (let* ((area (org-src--contents-area datum)) (beg (copy-marker (nth 0 area))) (end (copy-marker (nth 1 area) t)) (old-edit-buffer (org-src--edit-buffer beg end)) (fixed table-fixed-width-mode) (contents (or contents (nth 2 area)))) (if (and old-edit-buffer (or (not org-src-ask-before-returning-to-edit-buffer) (y-or-n-p "Return to existing edit buffer ([n] will revert changes)? ")= )) ;; Move to existing buffer. (org-src-switch-to-buffer old-edit-buffer 'return) (setq-local org-src--return-point (point)) ; <------- ;; Discard old edit buffer. (when old-edit-buffer (with-current-buffer old-edit-buffer (org-src--remove-overlay)) (kill-buffer old-edit-buffer)) (let* ((org-mode-p (derived-mode-p 'org-mode)) (source-tab-width (if indent-tabs-mode tab-width 0)) (type (org-element-type datum)) (ind (org-with-wide-buffer (goto-char (org-element-property :begin datum)) (org-get-indentation))) (preserve-ind (and (memq type '(example-block src-block)) (or (org-element-property :preserve-indent datum) org-src-preserve-indentation))) ;; Store relative positions of mark (if any) and point ;; within the edited area. (point-coordinates (and (not remote) (org-src--coordinates (point) beg end))) (mark-coordinates (and (not remote) (org-region-active-p) (let ((m (mark))) (and (>=3D m beg) (>=3D end m) (org-src--coordinates m beg end))))) ;; Generate a new edit buffer. (buffer (generate-new-buffer name)) ;; Add an overlay on top of source. (overlay (org-src--make-source-overlay beg end buffer))) ;; Switch to edit buffer. (org-src-switch-to-buffer buffer 'edit) (setq-local table-fixed-width-mode fixed) ;; Insert contents. (insert contents) (remove-text-properties (point-min) (point-max) '(display nil invisible nil intangible nil)) (unless preserve-ind (org-do-remove-indentation)) (set-buffer-modified-p nil) (setq buffer-file-name nil) ;; Initialize buffer. (when (functionp initialize) (let ((org-inhibit-startup t)) (condition-case e (funcall initialize) (error (message "Initialization fails with: %S" (error-message-string e)))))) ;; Transmit buffer-local variables for exit function. It must ;; be done after initializing major mode, as this operation ;; may reset them otherwise. (setq-local org-src--tab-width source-tab-width) (setq-local org-src--from-org-mode org-mode-p) (setq-local org-src--beg-marker beg) (setq-local org-src--end-marker end) (setq-local org-src--remote remote) (setq-local org-src--source-type type) (setq-local org-src--block-indentation ind) (setq-local org-src--preserve-indentation preserve-ind) (setq-local org-src--overlay overlay) (setq-local org-src--allow-write-back write-back) ;; Start minor mode. (org-src-mode) ;; Move mark and point in edit buffer to the corresponding ;; location. (if remote (progn ;; Put point at first non read-only character after ;; leading blank. (goto-char (or (text-property-any (point-min) (point-max) 'read-only nil) (point-max))) (skip-chars-forward " \r\t\n")) ;; Set mark and point. (when mark-coordinates (org-src--goto-coordinates mark-coordinates (point-min) (point-max)) (push-mark (point) 'no-message t) (setq deactivate-mark nil)) (org-src--goto-coordinates point-coordinates (point-min) (point-max))))))) (defun org-edit-src-abort () "Abort editing of the src code and return to the Org buffer." (interactive) (let (org-src--allow-write-back) (org-edit-src-exit) (goto-char org-src--return-point))) ; <------- If you feel that this should be an independent bug report, I can do that. Also, if after you test and verify / approve, should you want it in diff format or anything else, let me know. =2D- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0