emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH 1/2] org-colview.el: Add missing save-excursion for org-colvi


From: Benjamin Motz
Subject: [O] [PATCH 1/2] org-colview.el: Add missing save-excursion for org-colview
Date: Sat, 07 Jul 2018 00:15:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

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.

>From a0bed174852a6c7c6904f44bb649be45669f7b9f Mon Sep 17 00:00:00 2001
From: Benjamin Motz <address@hidden>
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

Best regards,
Benjamin Motz

reply via email to

[Prev in Thread] Current Thread [Next in Thread]