[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-14 Thread Bastien
Daimrod daim...@gmail.com writes:

 In `org-fix-ellipsis-at-bol', the change wasn't
 : (save-excursion (set-window-start (selected-window) (window-start)))

 but
 : (save-excursion (set-window-start (selected-window) (point-min)))

 which is not a noop.

 But it does the wrong thing with isearch.

Yes, it was a silly mistake of mine.

 When isearch is done, that is, when it has found a match and we leave
 isearch with RET for example. Then it calls `isearch-done' which runs
 `org-fix-ellipsis-at-bol' because it is in `isearch-mode-end-hook' (I
 didn't look to find why).

The bug `org-fix-ellipsis-at-bol' is supposed to fix is this one:
sometimes when searching for a string and hitting RET, the beginning
of the buffer is hidden and there is a confusing ... at the top of
the window.  With the previous version (using `recenter'), those
ellipsis were removed by recentering.  My bold and kinda superstitious
hope was that `set-window-start' would have the same effect, but I
need to double-check this.  At least we don't have the warning.

-- 
 Bastien





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-13 Thread Nicolas Richard
Bastien b...@gnu.org writes:

 I've now fixed this in the maint and master branch of Org's
 repository.

Thanks for looking into it.

Perhaps this isn't the right place to ask, but I wonder how
(save-excursion (set-window-start (selected-window) (window-start)))
isn't a noop.

-- 
Nico.





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-13 Thread Bastien
Nicolas Richard theonewiththeevill...@yahoo.fr writes:

 Perhaps this isn't the right place to ask, but I wonder how
 (save-excursion (set-window-start (selected-window) (window-start)))
 isn't a noop.

Perhaps it is a noop -- The purpose of `org-fix-ellipsis-at-bol'
is to remove the ellipsis overlay that outline-mode may leave
when navigating through folded regions.  At least this was the
purpose of the original version, and using recenter did the
job.  I'll try to reproduce the original bug, see if the new
version of `org-fix-ellipsis-at-bol' does the job and if not,
why.

-- 
 Bastien





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-13 Thread Daimrod
Bastien b...@gnu.org writes:

 Nicolas Richard theonewiththeevill...@yahoo.fr writes:

 Perhaps this isn't the right place to ask, but I wonder how
 (save-excursion (set-window-start (selected-window) (window-start)))
 isn't a noop.

 Perhaps it is a noop -- The purpose of `org-fix-ellipsis-at-bol'
 is to remove the ellipsis overlay that outline-mode may leave
 when navigating through folded regions.  At least this was the
 purpose of the original version, and using recenter did the
 job.  I'll try to reproduce the original bug, see if the new
 version of `org-fix-ellipsis-at-bol' does the job and if not,
 why.

In `org-fix-ellipsis-at-bol', the change wasn't
: (save-excursion (set-window-start (selected-window) (window-start)))

but
: (save-excursion (set-window-start (selected-window) (point-min)))

which is not a noop.

But it does the wrong thing with isearch.

When isearch is done, that is, when it has found a match and we leave
isearch with RET for example. Then it calls `isearch-done' which runs
`org-fix-ellipsis-at-bol' because it is in `isearch-mode-end-hook' (I
didn't look to find why).

Because of this, if the pattern found isn't at the top of the buffer,
then the point won't be at the pattern, but at the top of the buffer.

Best,

--
Daimrod/Greg





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-12 Thread Nicolas Richard
Daimrod daim...@gmail.com writes:
 PS: The change about throwing an error when recentering a window
 that does not display the current buffer breaks ~37 tests in Org
 master branch, even with this fix.  I need to digg this further.

 Err, what's the rational behind this change?

It is meant to catch cases where recenter acts on the wrong window.
Think of the cases where (recenter) is called from within a timer or a
process filter function.

See the discussion entitled
 comint-preoutput-filter-functions and flickering redisplay in TTY
on emacs devel.

-- 
Nico.





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-12 Thread Daimrod
Nicolas Richard theonewiththeevill...@yahoo.fr writes:

 Daimrod daim...@gmail.com writes:
 PS: The change about throwing an error when recentering a window
 that does not display the current buffer breaks ~37 tests in Org
 master branch, even with this fix.  I need to digg this further.

 Err, what's the rational behind this change?

 It is meant to catch cases where recenter acts on the wrong window.
 Think of the cases where (recenter) is called from within a timer or a
 process filter function.

 See the discussion entitled
 comint-preoutput-filter-functions and flickering redisplay in TTY
 on emacs devel.

Thanks!

-- 
Daimrod/Greg





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-12 Thread Daimrod
Daimrod daim...@gmail.com writes:

 Nicolas Richard theonewiththeevill...@yahoo.fr writes:

 Daimrod daim...@gmail.com writes:
 PS: The change about throwing an error when recentering a window
 that does not display the current buffer breaks ~37 tests in Org
 master branch, even with this fix.  I need to digg this further.

 Err, what's the rational behind this change?

 It is meant to catch cases where recenter acts on the wrong window.
 Think of the cases where (recenter) is called from within a timer or a
 process filter function.

 See the discussion entitled
 comint-preoutput-filter-functions and flickering redisplay in TTY
 on emacs devel.

 Thanks!

Okay, so is there another fix than `(when (eq (current-buffer)
(window-buffer)))' or removing the call?

If not, why does it raise an error instead of doing nothing silently?

Best,

-- 
Daimrod/Greg





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-12 Thread Bastien
I've now fixed this in the maint and master branch of Org's
repository.

Firmly waiting for warnings from the CAR and CDR random checks!

-- 
 Bastien





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-12 Thread Daimrod
Daimrod daim...@gmail.com writes:

 Daimrod daim...@gmail.com writes:

 Nicolas Richard theonewiththeevill...@yahoo.fr writes:

 Daimrod daim...@gmail.com writes:
 PS: The change about throwing an error when recentering a window
 that does not display the current buffer breaks ~37 tests in Org
 master branch, even with this fix.  I need to digg this further.

 Err, what's the rational behind this change?

 It is meant to catch cases where recenter acts on the wrong window.
 Think of the cases where (recenter) is called from within a timer or a
 process filter function.

 See the discussion entitled
 comint-preoutput-filter-functions and flickering redisplay in TTY
 on emacs devel.

 Thanks!

 Okay, so is there another fix than `(when (eq (current-buffer)
 (window-buffer)))' or removing the call?

 If not, why does it raise an error instead of doing nothing silently?

I've read the fix in org-mode and I understand that it was a silly
question. Please ignore it.

Best,

-- 
Daimrod/Greg





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-12 Thread Bastien
Daimrod daim...@gmail.com writes:

 I've read the fix in org-mode and I understand that it was a silly
 question. Please ignore it.

Well, the whole thread gave me the guts to dive in and to find, as
often, how tiny the challenge was -- so thanks for soft-prodding!

-- 
 Bastien





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-11 Thread Daimrod
Bastien b...@altern.org writes:

 Nicolas Richard theonewiththeevill...@yahoo.fr writes:

 David Griffiths dogriffi...@gmail.com writes:
 Debugger entered--Lisp error: (error `recenter'ing a window that does
 not display current-buffer.)
 recenter((4))
 org-overview()

 So that's a duplicate of #17724. It is fixed in org-mode (upstream) master
 branch. The easy fix is to use emacs-24 branch :)

 (otherwise just remove that call to recenter in org-overview).

 PS: The change about throwing an error when recentering a window
 that does not display the current buffer breaks ~37 tests in Org
 master branch, even with this fix.  I need to digg this further.

Err, what's the rational behind this change?

In the meantime I've a simple fix (quickly tested for `org-agenda' which
was also broken).

From 659bc5072253967ee2737f668c8ac035a4b8aa32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20Jadi?= gregoire.j...@gmail.com
Date: Thu, 12 Jun 2014 10:14:16 +0900
Subject: [PATCH] Use `org-recenter' as a wrapper around `recenter'

* lisp/org.el (org-recenter): New function that behaves exactly like
`recenter' except that it sets the `current-buffer' to the buffer
displayed by the selected window.

(org-fix-ellipsis-at-bol)
(org-optimize-window-after-visibility-change)
(org-first-headline-recenter)
* contrib/lisp/org-index.el (org-index)
(org-index--create-new-index)
(org-index--do-head)
* contrib/lisp/org-toc.el (org-toc-goto)
* lisp/org-agenda.el (org-agenda-list)
(org-agenda-redo)
(org-recenter-heading)
(org-agenda-recenter)
* lisp/org-bibtex.el (org-execute-file-search-in-bibtex)
* lisp/org-clock.el (org-clock-goto)
* lisp/org-table.el (org-table-show-reference): Use `org-recenter' instead of `recenter'.
---
 contrib/lisp/org-index.el | 12 ++--
 contrib/lisp/org-toc.el   |  4 ++--
 lisp/org-agenda.el| 12 ++--
 lisp/org-bibtex.el|  2 +-
 lisp/org-clock.el |  2 +-
 lisp/org-table.el |  4 ++--
 lisp/org.el   | 13 +
 7 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/contrib/lisp/org-index.el b/contrib/lisp/org-index.el
index 64974eb..f77d64d 100644
--- a/contrib/lisp/org-index.el
+++ b/contrib/lisp/org-index.el
@@ -633,7 +633,7 @@ command \head\ for reference \237\.
   ;; simply go into table
   (goto-char org-index--below-hline)
   (show-subtree)
-  (recenter)
+  (org-recenter)
   (if what-adjusted
   (setq message-text Nothing to search for; at index table)
 (setq message-text At index table)))
@@ -1581,7 +1581,7 @@ retrieves the value of the count-column for reference 12.
 (org-id-goto id)
 (org-show-context)
 (show-subtree)
-(recenter 1)
+(org-recenter 1)
 (setq org-index-id id)
 (if (y-or-n-p This is your new index table. It is already set for this emacs session. Do you want to save its id to make it available for future emacs sessions too ? )
 (progn
@@ -1598,7 +1598,7 @@ retrieves the value of the count-column for reference 12.
 (goto-char org-index--point)
 (org-show-context)
 (show-subtree)
-(recenter 1)
+(org-recenter 1)
 (delete-other-windows)
 ;; show new index
 (select-window (split-window-vertically))
@@ -1606,7 +1606,7 @@ retrieves the value of the count-column for reference 12.
 (org-id-goto id)
 (org-show-context)
 (show-subtree)
-(recenter 1)
+(org-recenter 1)
 (error Please compare your existing index (upper window) and a temporary new one (lower window) to correct the previous error (\%s\); the explanations following the new index table should help. reason)
 
 
@@ -1778,12 +1778,12 @@ retrieves the value of the count-column for reference 12.
 (pop-to-buffer buffer)
 (goto-char point)
 (org-reveal t)
-(recenter)
+(org-recenter)
 (pop-to-buffer *org-index-occur*))
 (org-pop-to-buffer-same-window buffer)
 (goto-char point)
 (org-reveal t)
-(recenter)))
+(org-recenter)))
   (setq message-text (format Did not find '%s' (or ref link))
 message-text))
 
diff --git a/contrib/lisp/org-toc.el b/contrib/lisp/org-toc.el
index 255b79e..e06de55 100644
--- a/contrib/lisp/org-toc.el
+++ b/contrib/lisp/org-toc.el
@@ -294,8 +294,8 @@ If CYCLE is non-nil, cycle the targeted subtree in the Org window.
 	   (org-show-entry))
 	 (org-show-context)))
 (if org-toc-recenter-mode
-	(if (= org-toc-recenter 1000) (recenter)
-	  (recenter org-toc-recenter)))
+	(if (= org-toc-recenter 1000) (org-recenter)
+	  (org-recenter org-toc-recenter)))
 (cond ((null jump)
 	   (switch-to-buffer-other-window toc-buf))
 	  ((eq jump 'delete)
diff --git 

[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-11 Thread Stefan Monnier
 +(defun org-recenter (optional arg)
 +  Like `recenter' but ensure that the `current-buffer' is
 +properly set.
 +  (with-current-buffer (window-buffer)
 +(recenter arg)))
 
This doesn't make much sense: in many case (window-buffer) can be
a buffer completely unrelated to Org.


Stefan





[O] bug#17746: bug#17746: 24.4.50; byte-code: `recenter'ing a window that does not display current-buffer. when composing a message

2014-06-11 Thread Daimrod
Stefan Monnier monn...@iro.umontreal.ca writes:

 +(defun org-recenter (optional arg)
 +  Like `recenter' but ensure that the `current-buffer' is
 +properly set.
 +  (with-current-buffer (window-buffer)
 +(recenter arg)))
  
 This doesn't make much sense: in many case (window-buffer) can be
 a buffer completely unrelated to Org.

Hmm, what was the previous behaviour of `recenter'? (i.e. before it
reports an error)

Did it just do nothing?

Best,

-- 
Daimrod/Greg