all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Rohit Patnaik" <quanticle@quanticle.net>
To: "Ihor Radchenko" <yantar92@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Why do org-agenda-switch-to and org-agenda-goto put the point in different spots in the target buffer?
Date: Fri, 09 Sep 2022 15:00:37 -0500	[thread overview]
Message-ID: <eb910161-c4bc-4918-876c-f108a7b58510@www.fastmail.com> (raw)
In-Reply-To: <87y1usdeu0.fsf@localhost>

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

> org-agenda-switch-to jumps to the actual agenda match (usually a timestamp).
> It may or may not be close to the headline (think of active timestamp inside
> notes). Such behaviour, albeit undocumented, may be useful for some users. I'd
> rather not change it.

Okay, that makes sense.

> Recentering is purely a visual thing. It should be safe to add.

I've added the recentering behavior in the attached patch. The recentering part
was more important for me than the point jumping to the heading, because
sometimes the match would appear at the very top of the screen and I'd have to
scroll up manually to see the heading. If the screen is centered on the match,
then it's likely that the heading will also be visible in the window.

Thanks,
Rohit

[-- Attachment #2: 0001-org-agenda.el-Make-org-agenda-switch-to-recenter-on-.patch --]
[-- Type: application/octet-stream, Size: 2009 bytes --]

From c92917f09eb1b1ef043dd92c914bd88fa72e79d9 Mon Sep 17 00:00:00 2001
From: Rohit Patnaik <quanticle@quanticle.net>
Date: Fri, 9 Sep 2022 14:55:04 -0500
Subject: [PATCH] org-agenda.el: Make `org-agenda-switch-to' recenter on the
 match

* org-agenda.el (org-agenda-switch-to): Port the recentering behavior from
`org-agenda-goto' to `org-agenda-switch-to'.

This change centers the screen on the match that `org-agenda-switch-to' jumps to
when the user hits RET in the agenda buffer.  This prevents the match from
appearing at the very top or very bottom of the screen, allowing the user to see
more context around the match.

TINYCHANGE
---
 etc/ORG-NEWS       | 9 +++++++++
 lisp/org-agenda.el | 1 +
 2 files changed, 10 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index a7f32671e..82eca2d62 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -489,6 +489,15 @@ support in LaTeX.  The new =babel= syntax for loading languages via
 =ini= files and the new command =\babelprovide= (see:
 https://mirrors.ctan.org/macros/latex/required/babel/base/babel.pdf)
 are also supported.
+
+*** ~org-agenda-switch-to~ recenters the window on the agenda match
+
+~org-agenda-switch-to~ now recenters the window on the agenda match,
+similar to ~org-agenda-goto~. This ensures that the user can see more
+of the context for the agenda match, whereas previously the match may
+have appeared at the top of the window, requiring the user to scroll
+up to see the headline or other context around the match.
+
 * Version 9.5
 
 ** Important announcements and breaking changes
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 053232078..e9ab54527 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -9741,6 +9741,7 @@ displayed Org file fills the frame."
       (goto-char pos)
       (when (derived-mode-p 'org-mode)
 	(org-fold-show-context 'agenda)
+        (recenter (/ (window-height) 2))
 	(run-hooks 'org-agenda-after-show-hook)))))
 
 (defun org-agenda-goto-mouse (ev)
-- 
2.37.3.windows.1


  reply	other threads:[~2022-09-09 20:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09  5:49 Why do org-agenda-switch-to and org-agenda-goto put the point in different spots in the target buffer? Rohit Patnaik
2022-09-09 10:25 ` Ihor Radchenko
2022-09-09 20:00   ` Rohit Patnaik [this message]
2022-09-10  6:02     ` Ihor Radchenko
2022-09-11 13:30     ` Max Nikulin

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

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

  git send-email \
    --in-reply-to=eb910161-c4bc-4918-876c-f108a7b58510@www.fastmail.com \
    --to=quanticle@quanticle.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@gmail.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.