emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Pierre Téchoueyres" <pierre.techoueyres@free.fr>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-agenda-list: call recenter only when buffer is visible
Date: Wed, 04 Apr 2018 00:24:52 +0200	[thread overview]
Message-ID: <87370c2aiz.fsf@killashandra.ballybran.fr> (raw)

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

Hello org's developers,

I'm trying to correct the package `org-alert'
(https://github.com/spegoraro/org-alert) in order to not interfer with
the org-agenda buffer.

I've tried to call `org-agenda-list' inside a temp buffer. This could
work but the call to `recenter' throw an error which defeat the purpose
of temp buffer.

So could it be possible to apply the attached patch inside the
maintenance branch ? I see the unconditionnal call to `recenter' more as
an bug than a feature.

If it's not possible / desirable. Is there any function to achieve the
following goal : list the next scheduled / dead-lined events of today ?


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

From 664b3d560f6d4caa00500add879923945453b7a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= <pierre.techoueyres@free.fr>
Date: Wed, 28 Mar 2018 01:35:22 +0200
Subject: [PATCH] org-agenda.el Call `recenter' only if buffer has a window.

* lisp/org-agenda.el (org-agenda-list): Condition the call to
  `recenter` only when the buffer has a window associated.

This permit to call `org-agenda-list` in a `with-temp-buffer` like
below:

(with-temp-buffer
  (let ((org-agenda-sticky nil)
        (org-agenda-buffer-tmp-name (buffer-name)))
    (org-agenda-list 1)
    (buffer-string))
---
 lisp/org-agenda.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 649f5e2aa..cfe844536 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4274,14 +4274,15 @@ items if they have an hour specification like [h]h:mm."
 	  (insert tbl)))
       (goto-char (point-min))
       (or org-agenda-multi (org-agenda-fit-window-to-buffer))
-      (unless (and (pos-visible-in-window-p (point-min))
+      (when (get-buffer-window)
+	(unless (and (pos-visible-in-window-p (point-min))
 		   (pos-visible-in-window-p (point-max)))
 	(goto-char (1- (point-max)))
 	(recenter -1)
 	(if (not (pos-visible-in-window-p (or start-pos 1)))
 	    (progn
 	      (goto-char (or start-pos 1))
-	      (recenter 1))))
+	      (recenter 1)))))
       (goto-char (or start-pos 1))
       (add-text-properties (point-min) (point-max)
 			   `(org-agenda-type agenda
-- 
2.14.3


             reply	other threads:[~2018-04-03 22:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03 22:24 Pierre Téchoueyres [this message]
2018-04-05 14:46 ` [PATCH] org-agenda-list: call recenter only when buffer is visible Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87370c2aiz.fsf@killashandra.ballybran.fr \
    --to=pierre.techoueyres@free.fr \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).