From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pierre =?utf-8?Q?T=C3=A9choueyres?= Subject: [PATCH] org-agenda-list: call recenter only when buffer is visible Date: Wed, 04 Apr 2018 00:24:52 +0200 Message-ID: <87370c2aiz.fsf@killashandra.ballybran.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3UMK-0002JL-2A for emacs-orgmode@gnu.org; Tue, 03 Apr 2018 18:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3UMI-0004jD-Vj for emacs-orgmode@gnu.org; Tue, 03 Apr 2018 18:24:56 -0400 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:36750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f3UMI-0004iP-Nt for emacs-orgmode@gnu.org; Tue, 03 Apr 2018 18:24:54 -0400 Received: from killashandra.ballybran.fr.free.fr (unknown [IPv6:2a01:e35:2e14:eab0:b51f:3dc7:7e03:942]) by smtp4-g21.free.fr (Postfix) with ESMTPS id AADEA19F58C for ; Wed, 4 Apr 2018 00:24:52 +0200 (CEST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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 ? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-agenda.el-Call-recenter-only-if-buffer-has-a-win.patch Content-Description: org-agenda-patch >From 664b3d560f6d4caa00500add879923945453b7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20T=C3=A9choueyres?= 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 --=-=-=--