emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 1/2] org-colview.el: Add missing save-excursion for org-colview
@ 2018-07-06 22:15 Benjamin Motz
  2018-07-07  7:28 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Motz @ 2018-07-06 22:15 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

Hello,

without this fix, point will jump to beginning of buffer each time the
column view is activated. This was annoying to me and I'd consider it a
bug. I'm not sure if this is the best way to fix the behaviour...

It's a TINYCHANGE when ignoring space-change.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 4204 bytes --]

From a0bed174852a6c7c6904f44bb649be45669f7b9f Mon Sep 17 00:00:00 2001
From: Benjamin Motz <benni.motz@gmail.com>
Date: Tue, 3 Jul 2018 19:36:21 +0200
Subject: [PATCH 1/2] org-colview.el: Add missing save-excursion for
 org-colview

Without this fix, point will jump to beginning of buffer each time the
column view is activated.

TINYCHANGE
---
 lisp/org-colview.el | 77 +++++++++++++++++++++++++++--------------------------
 1 file changed, 39 insertions(+), 38 deletions(-)

diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 82a0ae0..70710aa 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -807,44 +807,45 @@ view for the whole buffer unconditionally.
 
 When COLUMNS-FMT-STRING is non-nil, use it as the column format."
   (interactive "P")
-  (org-columns-remove-overlays)
-  (when global (goto-char (point-min)))
-  (if (markerp org-columns-begin-marker)
-      (move-marker org-columns-begin-marker (point))
-    (setq org-columns-begin-marker (point-marker)))
-  (org-columns-goto-top-level)
-  ;; Initialize `org-columns-current-fmt' and
-  ;; `org-columns-current-fmt-compiled'.
-  (let ((org-columns--time (float-time (current-time))))
-    (org-columns-get-format columns-fmt-string)
-    (unless org-columns-inhibit-recalculation (org-columns-compute-all))
-    (save-excursion
-      (save-restriction
-	(when (and (not global) (org-at-heading-p))
-	  (narrow-to-region (point) (org-end-of-subtree t t)))
-	(when (assoc "CLOCKSUM" org-columns-current-fmt-compiled)
-	  (org-clock-sum))
-	(when (assoc "CLOCKSUM_T" org-columns-current-fmt-compiled)
-	  (org-clock-sum-today))
-	(let ((cache
-	       ;; Collect contents of columns ahead of time so as to
-	       ;; compute their maximum width.
-	       (org-map-entries
-		(lambda () (cons (point) (org-columns--collect-values)))
-		nil nil (and org-columns-skip-archived-trees 'archive))))
-	  (when cache
-	    (org-columns--set-widths cache)
-	    (org-columns--display-here-title)
-	    (when (setq-local org-columns-flyspell-was-active
-			      (bound-and-true-p flyspell-mode))
-	      (flyspell-mode 0))
-	    (unless (local-variable-p 'org-colview-initial-truncate-line-value)
-	      (setq-local org-colview-initial-truncate-line-value
-			  truncate-lines))
-	    (setq truncate-lines t)
-	    (dolist (entry cache)
-	      (goto-char (car entry))
-	      (org-columns--display-here (cdr entry)))))))))
+  (save-excursion
+   (org-columns-remove-overlays)
+   (when global (goto-char (point-min)))
+   (if (markerp org-columns-begin-marker)
+       (move-marker org-columns-begin-marker (point))
+     (setq org-columns-begin-marker (point-marker)))
+   (org-columns-goto-top-level)
+   ;; Initialize `org-columns-current-fmt' and
+   ;; `org-columns-current-fmt-compiled'.
+   (let ((org-columns--time (float-time (current-time))))
+     (org-columns-get-format columns-fmt-string)
+     (unless org-columns-inhibit-recalculation (org-columns-compute-all))
+     (save-excursion
+       (save-restriction
+	 (when (and (not global) (org-at-heading-p))
+	   (narrow-to-region (point) (org-end-of-subtree t t)))
+	 (when (assoc "CLOCKSUM" org-columns-current-fmt-compiled)
+	   (org-clock-sum))
+	 (when (assoc "CLOCKSUM_T" org-columns-current-fmt-compiled)
+	   (org-clock-sum-today))
+	 (let ((cache
+		;; Collect contents of columns ahead of time so as to
+		;; compute their maximum width.
+		(org-map-entries
+		 (lambda () (cons (point) (org-columns--collect-values)))
+		 nil nil (and org-columns-skip-archived-trees 'archive))))
+	   (when cache
+	     (org-columns--set-widths cache)
+	     (org-columns--display-here-title)
+	     (when (setq-local org-columns-flyspell-was-active
+			       (bound-and-true-p flyspell-mode))
+	       (flyspell-mode 0))
+	     (unless (local-variable-p 'org-colview-initial-truncate-line-value)
+	       (setq-local org-colview-initial-truncate-line-value
+			   truncate-lines))
+	     (setq truncate-lines t)
+	     (dolist (entry cache)
+	       (goto-char (car entry))
+	       (org-columns--display-here (cdr entry))))))))))
 
 (defun org-columns-new (&optional spec &rest attributes)
   "Insert a new column, to the left of the current column.
-- 
2.7.4


[-- Attachment #3: Type: text/plain, Size: 29 bytes --]


Best regards,
Benjamin Motz

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] org-colview.el: Add missing save-excursion for org-colview
  2018-07-06 22:15 [PATCH 1/2] org-colview.el: Add missing save-excursion for org-colview Benjamin Motz
@ 2018-07-07  7:28 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2018-07-07  7:28 UTC (permalink / raw)
  To: Benjamin Motz; +Cc: emacs-orgmode

Hello,

Benjamin Motz <benni.motz@gmail.com> writes:

> without this fix, point will jump to beginning of buffer each time the
> column view is activated. This was annoying to me and I'd consider it a
> bug. I'm not sure if this is the best way to fix the behaviour...

Thank you. I applied a slightly different fix which doesn't duplicate
`save-excursion' calls.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-07  7:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06 22:15 [PATCH 1/2] org-colview.el: Add missing save-excursion for org-colview Benjamin Motz
2018-07-07  7:28 ` Nicolas Goaziou

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).