emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers
@ 2019-11-16 18:22 ian martins
  2019-11-17  6:12 ` Adam Porter
  0 siblings, 1 reply; 4+ messages in thread
From: ian martins @ 2019-11-16 18:22 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 25 bytes --]

Hi. Tiny patch enclosed.

[-- Attachment #1.2: Type: text/html, Size: 61 bytes --]

[-- Attachment #2: 0001-org-timer.el-Allow-org-timer-set-timer-from-non-Org-.patch --]
[-- Type: text/x-patch, Size: 1643 bytes --]

From d2af2e877147cc7be1f0c40455c9091f130c2159 Mon Sep 17 00:00:00 2001
From: ian <ianxm@jhu.edu>
Date: Sat, 16 Nov 2019 13:18:17 -0500
Subject: [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers

* org-timer.el (org-timer--get-timer-title): If the current buffer is
not an Org buffer, use the buffer name as the timer title.

Currently all of the `org-timer-' operations work from any buffer
except `org-timer-set-timer' which must be run from an Org buffer.
This is because `org-timer-set-timer' sets a timer name based on an
Org heading or filename.  By setting the timer title to the current
buffer name we can use `org-timer-set-timer' from any buffer and
preserve the timer naming convention of using the buffer name if there
isn't an Org header.

TINYCHANGE
---
 lisp/org-timer.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index 9674219..4367869 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -466,7 +466,8 @@ time is up."
 		 (run-hooks 'org-timer-done-hook)))))
 
 (defun org-timer--get-timer-title ()
-  "Construct timer title from heading or file name of Org buffer."
+  "Construct timer title.
+Try to us an Org header, otherwise use the buffer name."
   (cond
    ((derived-mode-p 'org-agenda-mode)
     (let* ((marker (or (get-text-property (point) 'org-marker)
@@ -482,7 +483,7 @@ time is up."
    ((derived-mode-p 'org-mode)
     (or (ignore-errors (org-get-heading))
 	(buffer-name (buffer-base-buffer))))
-   (t (error "Not in an Org buffer"))))
+   (t (buffer-name (buffer-base-buffer)))))
 
 (provide 'org-timer)
 
-- 
2.7.4


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

* Re: [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers
  2019-11-16 18:22 [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers ian martins
@ 2019-11-17  6:12 ` Adam Porter
  0 siblings, 0 replies; 4+ messages in thread
From: Adam Porter @ 2019-11-17  6:12 UTC (permalink / raw)
  To: emacs-orgmode

Hi Ian,

There's a small typo in the docstring.  :)

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

* [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers
@ 2019-11-17 11:50 ian martins
  2019-11-17 23:09 ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: ian martins @ 2019-11-17 11:50 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 194 bytes --]

> There's a small typo in the docstring.  :)

So sorry. I reworded it enough times that I should have known it was bound
to be wrong.

Here is an update so Kyle won't have to clean it up later.

[-- Attachment #1.2: Type: text/html, Size: 282 bytes --]

[-- Attachment #2: 0001-org-timer.el-Allow-org-timer-set-timer-from-non-Org-.patch --]
[-- Type: text/x-patch, Size: 1644 bytes --]

From f2271696889da6fded812b74c452571729e54384 Mon Sep 17 00:00:00 2001
From: ian <ianxm@jhu.edu>
Date: Sat, 16 Nov 2019 13:18:17 -0500
Subject: [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers

* org-timer.el (org-timer--get-timer-title): If the current buffer is
not an Org buffer, use the buffer name as the timer title.

Currently all of the `org-timer-' operations work from any buffer
except `org-timer-set-timer' which must be run from an Org buffer.
This is because `org-timer-set-timer' sets a timer name based on an
Org heading or filename.  By setting the timer title to the current
buffer name we can use `org-timer-set-timer' from any buffer and
preserve the timer naming convention of using the buffer name if there
isn't an Org header.

TINYCHANGE
---
 lisp/org-timer.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org-timer.el b/lisp/org-timer.el
index 9674219..68fe966 100644
--- a/lisp/org-timer.el
+++ b/lisp/org-timer.el
@@ -466,7 +466,8 @@ time is up."
 		 (run-hooks 'org-timer-done-hook)))))
 
 (defun org-timer--get-timer-title ()
-  "Construct timer title from heading or file name of Org buffer."
+  "Construct timer title.
+Try to use an Org header, otherwise use the buffer name."
   (cond
    ((derived-mode-p 'org-agenda-mode)
     (let* ((marker (or (get-text-property (point) 'org-marker)
@@ -482,7 +483,7 @@ time is up."
    ((derived-mode-p 'org-mode)
     (or (ignore-errors (org-get-heading))
 	(buffer-name (buffer-base-buffer))))
-   (t (error "Not in an Org buffer"))))
+   (t (buffer-name (buffer-base-buffer)))))
 
 (provide 'org-timer)
 
-- 
2.7.4


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

* Re: [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers
  2019-11-17 11:50 ian martins
@ 2019-11-17 23:09 ` Kyle Meyer
  0 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2019-11-17 23:09 UTC (permalink / raw)
  To: ian martins, emacs-orgmode

ian martins <ianxm@jhu.edu> writes:

> Subject: [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers
>
> * org-timer.el (org-timer--get-timer-title): If the current buffer is

The file name should include the directory, "lisp/".  (I'll add it.)

> not an Org buffer, use the buffer name as the timer title.
>
> Currently all of the `org-timer-' operations work from any buffer
> except `org-timer-set-timer' which must be run from an Org buffer.
> This is because `org-timer-set-timer' sets a timer name based on an
> Org heading or filename.  By setting the timer title to the current
> buffer name we can use `org-timer-set-timer' from any buffer and
> preserve the timer naming convention of using the buffer name if there
> isn't an Org header.

Makes sense.

> @@ -482,7 +483,7 @@ time is up."
>     ((derived-mode-p 'org-mode)
>      (or (ignore-errors (org-get-heading))
>  	(buffer-name (buffer-base-buffer))))
> -   (t (error "Not in an Org buffer"))))
> +   (t (buffer-name (buffer-base-buffer)))))

Looks good.  An alternative that avoids repeating the buffer-name call
would be

    (cond
     [...]
     ((and (derived-mode-p 'org-mode)
           (ignore-errors (org-get-heading))))
     (t (buffer-name (buffer-base-buffer))))

but I think it's fine as is.  Applied and pushed (044e9718c).

Thanks.

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

end of thread, other threads:[~2019-11-17 23:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-16 18:22 [PATCH] org-timer.el: Allow org-timer-set-timer from non-Org buffers ian martins
2019-11-17  6:12 ` Adam Porter
  -- strict thread matches above, loose matches on Subject: below --
2019-11-17 11:50 ian martins
2019-11-17 23:09 ` Kyle Meyer

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