emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Two patches I have been using for 6-12 months
@ 2014-06-14 14:46 Bernt Hansen
  2014-06-14 14:46 ` [PATCH 1/2] Remove striction when finding task by id Bernt Hansen
  2014-06-14 14:46 ` [PATCH 2/2] Keep window position in agenda when changing todo states Bernt Hansen
  0 siblings, 2 replies; 11+ messages in thread
From: Bernt Hansen @ 2014-06-14 14:46 UTC (permalink / raw)
  To: emacs-orgmode

Hi Bastien,

Attached are two patches I use on top of master.  I have been using these
for 6-12 months so I consider them to be well tested.

Please consider including these in the code base.

Thanks,
Bernt

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

* [PATCH 1/2] Remove striction when finding task by id
  2014-06-14 14:46 Two patches I have been using for 6-12 months Bernt Hansen
@ 2014-06-14 14:46 ` Bernt Hansen
  2014-06-14 15:12   ` Nicolas Goaziou
  2014-06-14 14:46 ` [PATCH 2/2] Keep window position in agenda when changing todo states Bernt Hansen
  1 sibling, 1 reply; 11+ messages in thread
From: Bernt Hansen @ 2014-06-14 14:46 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bernt Hansen

Allows find task by id to locate a task outside a current
restriction.  I restrict to subtrees regularly and when I want to
jump to another task outside the current restriction but in the
same file this patch is required to locate the appropriate
heading.  Without this patch point ends up at the top of my
restricted area which is on the wrong task.
---
 lisp/org-macs.el |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index ddd6e2e..e6af5da 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -154,9 +154,11 @@ We use a macro so that the test can happen at compilation time."
     `(let ((,mpom ,pom))
        (save-excursion
 	 (if (markerp ,mpom) (set-buffer (marker-buffer ,mpom)))
-	 (save-excursion
-	   (goto-char (or ,mpom (point)))
-	   ,@body)))))
+	 (save-restriction
+	   (widen)
+	   (save-excursion
+	     (goto-char (or ,mpom (point)))
+	     ,@body))))))
 (def-edebug-spec org-with-point-at (form body))
 (put 'org-with-point-at 'lisp-indent-function 1)
 
-- 
1.7.9.48.g85da4d

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

* [PATCH 2/2] Keep window position in agenda when changing todo states
  2014-06-14 14:46 Two patches I have been using for 6-12 months Bernt Hansen
  2014-06-14 14:46 ` [PATCH 1/2] Remove striction when finding task by id Bernt Hansen
@ 2014-06-14 14:46 ` Bernt Hansen
  2014-06-14 15:51   ` Bastien
  1 sibling, 1 reply; 11+ messages in thread
From: Bernt Hansen @ 2014-06-14 14:46 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bernt Hansen

Allow changing task state in agenda without moving point.  I
use this when reviewing projects weekly and I need to change the
state of some of the tasks.  I found jumping to the top of the
agenda after each state change especially annoying when it causes
the agenda to scroll.
---
 lisp/org-agenda.el |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 2d1bafe..d7632b4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -8907,9 +8907,10 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
 	    (org-agenda-highlight-todo 'line)
 	    (beginning-of-line 1))
 	   (t (error "Line update did not work")))
-	  (save-restriction
-	    (narrow-to-region (point-at-bol) (point-at-eol))
-	    (org-agenda-finalize)))
+	  (save-window-excursion
+	    (save-restriction
+	      (narrow-to-region (point-at-bol) (point-at-eol))
+	      (org-agenda-finalize))))
 	(beginning-of-line 0)))))
 
 (defun org-agenda-align-tags (&optional line)
-- 
1.7.9.48.g85da4d

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

* Re: [PATCH 1/2] Remove striction when finding task by id
  2014-06-14 14:46 ` [PATCH 1/2] Remove striction when finding task by id Bernt Hansen
@ 2014-06-14 15:12   ` Nicolas Goaziou
  2014-06-14 15:25     ` Bernt Hansen
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2014-06-14 15:12 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Hello,

Bernt Hansen <bernt@norang.ca> writes:

> Allows find task by id to locate a task outside a current
> restriction.  I restrict to subtrees regularly and when I want to
> jump to another task outside the current restriction but in the
> same file this patch is required to locate the appropriate
> heading.  Without this patch point ends up at the top of my
> restricted area which is on the wrong task.

Thank you. Could you provide a changelog with that?

> +	 (save-restriction
> +	   (widen)
> +	   (save-excursion

`save-restriction' + `widen' + `save-excursion' = `org-with-wide-buffer'


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH 1/2] Remove striction when finding task by id
  2014-06-14 15:12   ` Nicolas Goaziou
@ 2014-06-14 15:25     ` Bernt Hansen
  2014-06-15  2:50       ` [PATCH] Remove restriction when locating markers Bernt Hansen
  0 siblings, 1 reply; 11+ messages in thread
From: Bernt Hansen @ 2014-06-14 15:25 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Thank you. Could you provide a changelog with that?
>
>> +	 (save-restriction
>> +	   (widen)
>> +	   (save-excursion
>
> `save-restriction' + `widen' + `save-excursion' = `org-with-wide-buffer'

Sure thing!

I will update and resend both later today.

(and fix the typo in 'restriction' in the subject above)

Thanks,
Bernt

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

* Re: [PATCH 2/2] Keep window position in agenda when changing todo states
  2014-06-14 14:46 ` [PATCH 2/2] Keep window position in agenda when changing todo states Bernt Hansen
@ 2014-06-14 15:51   ` Bastien
  2014-06-14 17:01     ` Bernt Hansen
  0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2014-06-14 15:51 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Hi Bernt,

Bernt Hansen <bernt@norang.ca> writes:

> Allow changing task state in agenda without moving point.  I
> use this when reviewing projects weekly and I need to change the
> state of some of the tasks.  I found jumping to the top of the
> agenda after each state change especially annoying when it causes
> the agenda to scroll.

I think the bug this patches is supposed to fix (i.e. point jumping
at the top when changing the state of an agenda item) does not exist
anymore, neither in the maint branch nor in the master one.

Can you double-check?

Also, `save-window-excursion' is sort of a brute-force approach when
we only need to save the point position in a window.  There is a big
warning in `save-window-excursion' docstring that I slowly learned to
appreciate...

Anyway, I just looked at it quickly, maybe that's a correct fix.
Thanks for further confirmation.

-- 
 Bastien

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

* Re: [PATCH 2/2] Keep window position in agenda when changing todo states
  2014-06-14 15:51   ` Bastien
@ 2014-06-14 17:01     ` Bernt Hansen
  2014-06-14 17:45       ` Bernt Hansen
  0 siblings, 1 reply; 11+ messages in thread
From: Bernt Hansen @ 2014-06-14 17:01 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode@gnu.org

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

Will check. Thanks. 

Bernt

> On Jun 14, 2014, at 11:51 AM, Bastien <bzg@gnu.org> wrote:
> 
> Hi Bernt,
> 
> Bernt Hansen <bernt@norang.ca> writes:
> 
>> Allow changing task state in agenda without moving point.  I
>> use this when reviewing projects weekly and I need to change the
>> state of some of the tasks.  I found jumping to the top of the
>> agenda after each state change especially annoying when it causes
>> the agenda to scroll.
> 
> I think the bug this patches is supposed to fix (i.e. point jumping
> at the top when changing the state of an agenda item) does not exist
> anymore, neither in the maint branch nor in the master one.
> 
> Can you double-check?
> 
> Also, `save-window-excursion' is sort of a brute-force approach when
> we only need to save the point position in a window.  There is a big
> warning in `save-window-excursion' docstring that I slowly learned to
> appreciate...
> 
> Anyway, I just looked at it quickly, maybe that's a correct fix.
> Thanks for further confirmation.
> 
> -- 
> Bastien

[-- Attachment #2: Type: text/html, Size: 1916 bytes --]

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

* Re: [PATCH 2/2] Keep window position in agenda when changing todo states
  2014-06-14 17:01     ` Bernt Hansen
@ 2014-06-14 17:45       ` Bernt Hansen
  2014-06-15  7:34         ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: Bernt Hansen @ 2014-06-14 17:45 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode@gnu.org

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

Yes you are correct. This patch is no longer required.
Please disregard this patch. 

Thanks,
Bernt

> On Jun 14, 2014, at 1:01 PM, Bernt Hansen <bernt@norang.ca> wrote:
> 
> Will check. Thanks. 
> 
> Bernt
> 
>> On Jun 14, 2014, at 11:51 AM, Bastien <bzg@gnu.org> wrote:
>> 
>> Hi Bernt,
>> 
>> Bernt Hansen <bernt@norang.ca> writes:
>> 
>>> Allow changing task state in agenda without moving point.  I
>>> use this when reviewing projects weekly and I need to change the
>>> state of some of the tasks.  I found jumping to the top of the
>>> agenda after each state change especially annoying when it causes
>>> the agenda to scroll.
>> 
>> I think the bug this patches is supposed to fix (i.e. point jumping
>> at the top when changing the state of an agenda item) does not exist
>> anymore, neither in the maint branch nor in the master one.
>> 
>> Can you double-check?
>> 
>> Also, `save-window-excursion' is sort of a brute-force approach when
>> we only need to save the point position in a window.  There is a big
>> warning in `save-window-excursion' docstring that I slowly learned to
>> appreciate...
>> 
>> Anyway, I just looked at it quickly, maybe that's a correct fix.
>> Thanks for further confirmation.
>> 
>> -- 
>> Bastien

[-- Attachment #2: Type: text/html, Size: 2353 bytes --]

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

* [PATCH] Remove restriction when locating markers
  2014-06-14 15:25     ` Bernt Hansen
@ 2014-06-15  2:50       ` Bernt Hansen
  2014-06-15  7:31         ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Bernt Hansen @ 2014-06-15  2:50 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bernt Hansen

* org-macs.el: Remove restriction when locating markers

Allows org-with-point-at to locate point outside the current
restriction.
---
 lisp/org-macs.el |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index ddd6e2e..96265ec 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -154,9 +154,9 @@ We use a macro so that the test can happen at compilation time."
     `(let ((,mpom ,pom))
        (save-excursion
 	 (if (markerp ,mpom) (set-buffer (marker-buffer ,mpom)))
-	 (save-excursion
-	   (goto-char (or ,mpom (point)))
-	   ,@body)))))
+	 (org-with-wide-buffer
+	  (goto-char (or ,mpom (point)))
+	  ,@body)))))
 (def-edebug-spec org-with-point-at (form body))
 (put 'org-with-point-at 'lisp-indent-function 1)
 
-- 
1.7.9.48.g85da4d

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

* Re: [PATCH] Remove restriction when locating markers
  2014-06-15  2:50       ` [PATCH] Remove restriction when locating markers Bernt Hansen
@ 2014-06-15  7:31         ` Nicolas Goaziou
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Goaziou @ 2014-06-15  7:31 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Hello,

Bernt Hansen <bernt@norang.ca> writes:

> * org-macs.el: Remove restriction when locating markers
>
> Allows org-with-point-at to locate point outside the current
> restriction.

Applied. Thank you.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH 2/2] Keep window position in agenda when changing todo states
  2014-06-14 17:45       ` Bernt Hansen
@ 2014-06-15  7:34         ` Bastien
  0 siblings, 0 replies; 11+ messages in thread
From: Bastien @ 2014-06-15  7:34 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode@gnu.org

Bernt Hansen <bernt@norang.ca> writes:

> Please disregard this patch.

Done -- thanks for double-checking,

-- 
 Bastien

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

end of thread, other threads:[~2014-06-15  7:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-14 14:46 Two patches I have been using for 6-12 months Bernt Hansen
2014-06-14 14:46 ` [PATCH 1/2] Remove striction when finding task by id Bernt Hansen
2014-06-14 15:12   ` Nicolas Goaziou
2014-06-14 15:25     ` Bernt Hansen
2014-06-15  2:50       ` [PATCH] Remove restriction when locating markers Bernt Hansen
2014-06-15  7:31         ` Nicolas Goaziou
2014-06-14 14:46 ` [PATCH 2/2] Keep window position in agenda when changing todo states Bernt Hansen
2014-06-14 15:51   ` Bastien
2014-06-14 17:01     ` Bernt Hansen
2014-06-14 17:45       ` Bernt Hansen
2014-06-15  7:34         ` Bastien

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