emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* point moves and zoom level reverts when refreshing agenda
@ 2018-05-27 21:19 Samuel Wales
  2018-05-27 21:24 ` Samuel Wales
  2018-05-29 16:22 ` Marco Wahl
  0 siblings, 2 replies; 9+ messages in thread
From: Samuel Wales @ 2018-05-27 21:19 UTC (permalink / raw)
  To: emacs-orgmode

recent maint, have not tried in -Q.

summary: point moves and zoom level reverts when refreshing agenda

1]

i find that,

when i do an agenda agenda [daily/weekly] and i have point on a task,

and i go do something in the task and nearby nodes, and a bunch of
other things, and return to the agenda,

and refresh agenda view [and also just in case any of the markers god
out of date and could cause corruption if i operated on a task from
the agenda],

that point moves from the task.  i wonder if it makes sense to try to
keep point on the task that it was on?

2] i also find that refreshing resets the zoom level created using
text-scale-increase.  i wonder if this can also be preserved.  to me,
refreshing refers to updating the contents of the agenda view, not
things like text scale.

thanks.

-- 
The Kafka Pandemic: <http://thekafkapandemic.blogspot.com>

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." ---
<http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>.

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

* Re: point moves and zoom level reverts when refreshing agenda
  2018-05-27 21:19 point moves and zoom level reverts when refreshing agenda Samuel Wales
@ 2018-05-27 21:24 ` Samuel Wales
  2018-05-29 16:22 ` Marco Wahl
  1 sibling, 0 replies; 9+ messages in thread
From: Samuel Wales @ 2018-05-27 21:24 UTC (permalink / raw)
  To: emacs-orgmode

On 5/27/18, Samuel Wales <samologist@gmail.com> wrote:
> 2] i also find that refreshing resets the zoom level created using
> text-scale-increase.  i wonder if this can also be preserved.  to me,
> refreshing refers to updating the contents of the agenda view, not
> things like text scale.

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

* Re: point moves and zoom level reverts when refreshing agenda
  2018-05-27 21:19 point moves and zoom level reverts when refreshing agenda Samuel Wales
  2018-05-27 21:24 ` Samuel Wales
@ 2018-05-29 16:22 ` Marco Wahl
  2018-06-05 14:18   ` Marco Wahl
  1 sibling, 1 reply; 9+ messages in thread
From: Marco Wahl @ 2018-05-29 16:22 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi Samuel,

> recent maint, have not tried in -Q.

Me neither.  ;)

> summary: point moves and zoom level reverts when refreshing agenda
>
> 1]
>
> i find that,
>
> when i do an agenda agenda [daily/weekly] and i have point on a task,
>
> and i go do something in the task and nearby nodes, and a bunch of
> other things, and return to the agenda,
>
> and refresh agenda view [and also just in case any of the markers god
> out of date and could cause corruption if i operated on a task from
> the agenda],
>
> that point moves from the task.  i wonder if it makes sense to try to
> keep point on the task that it was on?

I also find the point movement erratic sometimes in the agenda.  IIUC
the line number gets stored for the agenda and after agenda-redo point
is set to that line number again.

I also thought a bit about a better behavior.  One could implement a
heuristic which trys to place point at a line which looks "very much"
like the line which contained point before the redo.  But I'm not sure
how crazy that is.

> 2] i also find that refreshing resets the zoom level created using
> text-scale-increase.  i wonder if this can also be preserved.  to me,
> refreshing refers to updating the contents of the agenda view, not
> things like text scale.

This is a wanted feature AFAICT.  I think the following patch is a
reliable way to achieve the preservation of text-scale for agenda-redo.


Ciao,
     Marco


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-agenda-Keep-text-scale-at-agenda-redo.patch --]
[-- Type: text/x-patch, Size: 1452 bytes --]

From 7952540977a5281310edf190c81b8d811218d6ed Mon Sep 17 00:00:00 2001
From: Marco Wahl <marcowahlsoft@gmail.com>
Date: Tue, 29 May 2018 17:59:46 +0200
Subject: [PATCH] org-agenda: Keep text-scale at agenda-redo

* lisp/org-agenda.el (org-agenda-redo):  Save and restore `text-scale-mode-amount'.
---
 lisp/org-agenda.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 24b752498..8eab8fe43 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7318,7 +7318,9 @@ in the agenda."
 		   (cons (or cpa (car last-args)) (cdr last-args)))
 		  ((stringp last-args)
 		   last-args))))
-	 (series-redo-cmd (get-text-property p 'org-series-redo-cmd)))
+	 (series-redo-cmd (get-text-property p 'org-series-redo-cmd))
+	 (before-text-scale-mode-amount
+	  (when (boundp' text-scale-mode-amount) text-scale-mode-amount)))
     (put 'org-agenda-tag-filter :preset-filter nil)
     (put 'org-agenda-category-filter :preset-filter nil)
     (put 'org-agenda-regexp-filter :preset-filter nil)
@@ -7350,6 +7352,7 @@ in the agenda."
       (when re  (org-agenda-filter-apply re 'regexp)))
     (and top-hl-filter (org-agenda-filter-top-headline-apply top-hl-filter))
     (and cols (called-interactively-p 'any) (org-agenda-columns))
+    (and before-text-scale-mode-amount (text-scale-set before-text-scale-mode-amount))
     (org-goto-line line)
     (recenter window-line)))
 
-- 
2.17.0


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

* Re: point moves and zoom level reverts when refreshing agenda
  2018-05-29 16:22 ` Marco Wahl
@ 2018-06-05 14:18   ` Marco Wahl
  2018-06-05 19:00     ` Samuel Wales
  0 siblings, 1 reply; 9+ messages in thread
From: Marco Wahl @ 2018-06-05 14:18 UTC (permalink / raw)
  To: emacs-orgmode

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


>> 2] i also find that refreshing resets the zoom level created using
>> text-scale-increase.  i wonder if this can also be preserved.  to me,
>> refreshing refers to updating the contents of the agenda view, not
>> things like text scale.
>
> This is a wanted feature AFAICT.  I think the following patch is a
> reliable way to achieve the preservation of text-scale for agenda-redo.

The following is an alternative patch which I think is preferable.  It
just keeps the needed local variables for the text-scale (aka zoom) in
good order in function org-agenda-mode.

Further I use this patch already for some days and could not find any
issue.


Ciao,
     Marco


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-agenda-Keep-local-variables-defining-text-scale.patch --]
[-- Type: text/x-patch, Size: 2969 bytes --]

From 74aa62a7d777319f14896f3814cae474d947f3a7 Mon Sep 17 00:00:00 2001
From: Marco Wahl <marcowahlsoft@gmail.com>
Date: Mon, 4 Jun 2018 15:17:29 +0200
Subject: [PATCH] org-agenda: Keep local-variables defining text-scale

* lisp/org-agenda.el (org-agenda-mode): Save and restore local
	   variables text-scale-mode-amount, text-scale-mode,
	   text-scale-mode-lighter, face-remapping-alist.  In effect
	   this keeps the text-scale at agenda rebuild and redo.

This commit is predicated on the newsgroup post of Samuel Wales "point
moves and zoom level reverts when refreshing agenda" at Sun, 27 May
2018.
---
 lisp/org-agenda.el | 44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 24b752498..4b95b8c59 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2184,29 +2184,37 @@ The following commands are available:
 
 \\{org-agenda-mode-map}"
   (interactive)
-  (cond (org-agenda-doing-sticky-redo
-	 ;; Refreshing sticky agenda-buffer
-	 ;;
-	 ;; Preserve the value of `org-agenda-local-vars' variables,
-	 ;; while letting `kill-all-local-variables' kill the rest
-	 (let ((save (buffer-local-variables)))
-	   (kill-all-local-variables)
+  (let ((agenda-local-vars-to-keep
+	 '(text-scale-mode-amount
+	   text-scale-mode
+	   text-scale-mode-lighter
+	   face-remapping-alist))
+	(save (buffer-local-variables)))
+    (kill-all-local-variables)
+    (cond (org-agenda-doing-sticky-redo
+	   ;; Refreshing sticky agenda-buffer
+	   ;;
+	   ;; Preserve the value of `org-agenda-local-vars' variables.
 	   (mapc #'make-local-variable org-agenda-local-vars)
 	   (dolist (elem save)
 	     (pcase elem
 	       (`(,var . ,val)		;ignore unbound variables
 		(when (and val (memq var org-agenda-local-vars))
-		  (set var val))))))
-	 (setq-local org-agenda-this-buffer-is-sticky t))
-	(org-agenda-sticky
-	 ;; Creating a sticky Agenda buffer for the first time
-	 (kill-all-local-variables)
-	 (mapc 'make-local-variable org-agenda-local-vars)
-	 (setq-local org-agenda-this-buffer-is-sticky t))
-	(t
-	 ;; Creating a non-sticky agenda buffer
-	 (kill-all-local-variables)
-	 (setq-local org-agenda-this-buffer-is-sticky nil)))
+		  (set var val)))))
+	   (setq-local org-agenda-this-buffer-is-sticky t))
+	  (org-agenda-sticky
+	   ;; Creating a sticky Agenda buffer for the first time
+	   (mapc 'make-local-variable org-agenda-local-vars)
+	   (setq-local org-agenda-this-buffer-is-sticky t))
+	  (t
+	   ;; Creating a non-sticky agenda buffer
+	   (setq-local org-agenda-this-buffer-is-sticky nil)))
+    (mapc #'make-local-variable agenda-local-vars-to-keep)
+    (dolist (elem save)
+      (pcase elem
+	(`(,var . ,val)		;ignore unbound variables
+	 (when (and val (memq var agenda-local-vars-to-keep))
+	   (set var val))))))
   (setq org-agenda-undo-list nil
 	org-agenda-pending-undo-list nil
 	org-agenda-bulk-marked-entries nil)
-- 
2.17.1


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

* Re: point moves and zoom level reverts when refreshing agenda
  2018-06-05 14:18   ` Marco Wahl
@ 2018-06-05 19:00     ` Samuel Wales
  2018-06-05 20:35       ` Marco Wahl
  0 siblings, 1 reply; 9+ messages in thread
From: Samuel Wales @ 2018-06-05 19:00 UTC (permalink / raw)
  To: Marco Wahl; +Cc: emacs-orgmode

On 6/5/18, Marco Wahl <marcowahlsoft@gmail.com> wrote:
> The following is an alternative patch which I think is preferable.  It
> just keeps the needed local variables for the text-scale (aka zoom) in
> good order in function org-agenda-mode.

> Further I use this patch already for some days and could not find any
> issue.

thank you!  do you think this patch could be integrated into core?

-- 
The Kafka Pandemic: <http://thekafkapandemic.blogspot.com>

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." ---
<http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>.

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

* Re: point moves and zoom level reverts when refreshing agenda
  2018-06-05 19:00     ` Samuel Wales
@ 2018-06-05 20:35       ` Marco Wahl
  2018-06-19 18:22         ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Marco Wahl @ 2018-06-05 20:35 UTC (permalink / raw)
  To: emacs-orgmode


>> Further I use this patch already for some days and could not find any
>> issue.
>
> thank you!  do you think this patch could be integrated into core?

Yes, I think so.

Hopefully Nicolas and Bastien see it the same way.

BTW meanwhile you could overwrite function org-agenda-mode with the
patched version residing in your init file.


Bye,
    Marco

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

* Re: point moves and zoom level reverts when refreshing agenda
  2018-06-05 20:35       ` Marco Wahl
@ 2018-06-19 18:22         ` Nicolas Goaziou
  2018-06-24  8:15           ` Marco Wahl
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-06-19 18:22 UTC (permalink / raw)
  To: Marco Wahl; +Cc: emacs-orgmode

Hello,

Marco Wahl <marcowahlsoft@gmail.com> writes:

> Hopefully Nicolas and Bastien see it the same way.

Thank you. It looks good. Feel free to apply it.

I have two suggestions however:

1. There is some code duplication, e.g., (dolist ...), could this be
   factored out before applying the patch?

2. Would it make sense to add the variables to preserve in a dedicated
   top-level variable instead of burying them in the code?


Regards,

-- 
Nicolas Goaziou

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

* Re: point moves and zoom level reverts when refreshing agenda
  2018-06-19 18:22         ` Nicolas Goaziou
@ 2018-06-24  8:15           ` Marco Wahl
  2018-06-24 21:10             ` Samuel Wales
  0 siblings, 1 reply; 9+ messages in thread
From: Marco Wahl @ 2018-06-24  8:15 UTC (permalink / raw)
  To: emacs-orgmode

Bonjour!

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Thank you. It looks good. Feel free to apply it.

Thanks, I did.

> I have two suggestions however:
>
> 1. There is some code duplication, e.g., (dolist ...), could this be
>    factored out before applying the patch?

Yes, done, thanks for the hint.  The patch has been committed.

> 2. Would it make sense to add the variables to preserve in a dedicated
>    top-level variable instead of burying them in the code?

I don't know.  Possibly this is a YAGNI.  A top-level variable could be
introduced any time.  Further someone might come up with a freshly
rewritten agenda in the meantime. ;)

BTW: It might be a good idea to take ideas from `list-buffers' and
friends for the rewrite of the agenda.


Ciao,
     Marco

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

* Re: point moves and zoom level reverts when refreshing agenda
  2018-06-24  8:15           ` Marco Wahl
@ 2018-06-24 21:10             ` Samuel Wales
  0 siblings, 0 replies; 9+ messages in thread
From: Samuel Wales @ 2018-06-24 21:10 UTC (permalink / raw)
  To: Marco Wahl; +Cc: emacs-orgmode

On 6/24/18, Marco Wahl <marcowahlsoft@gmail.com> wrote:
> Bonjour!

merci a tout.

-- 
The Kafka Pandemic: <http://thekafkapandemic.blogspot.com>

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

"You’ve really gotta quit this and get moving, because this is murder
by neglect." ---
<http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>.

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

end of thread, other threads:[~2018-06-24 21:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-27 21:19 point moves and zoom level reverts when refreshing agenda Samuel Wales
2018-05-27 21:24 ` Samuel Wales
2018-05-29 16:22 ` Marco Wahl
2018-06-05 14:18   ` Marco Wahl
2018-06-05 19:00     ` Samuel Wales
2018-06-05 20:35       ` Marco Wahl
2018-06-19 18:22         ` Nicolas Goaziou
2018-06-24  8:15           ` Marco Wahl
2018-06-24 21:10             ` Samuel Wales

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).