From: pareto optimal <pareto.optimal@mailfence.com>
To: Emacs Orgmode <emacs-orgmode@gnu.org>
Subject: Re: RFC on implementation adding buttons beside headings
Date: Sat, 18 Feb 2023 17:01:27 +0100 (CET) [thread overview]
Message-ID: <418353827.205931.1676736087884@fidget.co-bxl> (raw)
In-Reply-To: <1495820062.205861.1676736033884@fidget.co-bxl>
[-- Attachment #1: Type: text/plain, Size: 3021 bytes --]
I forgot the implementation:
```
(define-button-type 'org-clock-in-button
'follow-link t
'face 'custom-button
'mouse-face 'custom-button-mouse
'action (lambda (b) (org-clock-in)))
(define-button-type 'org-clock-out-button
'follow-link t
'face 'custom-button
'mouse-face 'custom-button-mouse
'action (lambda (b) (org-clock-out)))
(defun has-clock-in-button ()
(s-contains? "Clock In" (nth 4 (org-heading-components))))
(defun has-clock-out-button ()
(s-contains? "Clock Out" (nth 4 (org-heading-components))))
(defun pod/add-clock-in-button-to-right-of-heading ()
(unless (has-clock-in-button)
(save-excursion
(org-end-of-line)
(let ((end-of-line-before-insert (point)))
(insert " Clock In")
(let* ((button-start (+ 4 end-of-line-before-insert))
(button-end (+ 8 button-start)))
(make-button button-start button-end :type 'org-clock-in-button))))))
;; (defun remove-clock-in-button ()
;; )
(defun pod/add-clock-out-button-to-right-of-heading ()
(unless (has-clock-out-button)
(outline-up-heading)
;; (remove-clock-in-button)
(save-excursion
(org-end-of-line)
(let ((end-of-line-before-insert (point)))
(insert " Clock Out")
(let* ((button-start (+ 4 end-of-line-before-insert))
(button-end (+ 9 button-start)))
(make-button button-start button-end :type 'org-clock-out-button))))))
(add-hook 'org-after-todo-state-change-hook #'pod/add-clock-in-button-to-right-of-heading)
(add-hook 'org-clock-in-hook #'pod/add-clock-out-button-to-right-of-heading)
(add-hook 'org-clock-out-hook #'pod/add-clock-in-button-to-right-of-heading)
```
On Feb 18, 2023 at 10:00 AM, pareto optimal <pareto.optimal@mailfence.com> wrote:
Hi all!
I've recently been playing with emacs on Android and wanted an easier way to clock in.
My idea was to put buttons beside org headings that are TODO items. I do this by:
- removing clocking buttons on heading if present, then adding a clock in button on 'org-after-todo-state-change-hook`
- removing clocking buttons on heading if present, then adding a clock out button on 'org-clock-in-hook
- removing clocking buttons on heading if present, then adding a clock in button on 'org-clock-out-hook
Well, the removing part isn't quite implemented yet but that's the idea. Otherwise what I'll paste below is a working implementation.
I'm new to using buttons and emacs and I found the only way to place the button where I wanted was to insert some blank space after the heading. Is that expected and best practice or is there some other way to do it?
Would this be something useful in core org-mode? I know at least a few friends who've asked me "why isn't there some button I can click by headings to clock in" when I showed them how I use org-mode.
I also welcome any other ideas or comments.
Thank you for your time.
ParetoOptimalDev
https://www.paretooptimal.dev/
[-- Attachment #2: Type: text/html, Size: 4356 bytes --]
next prev parent reply other threads:[~2023-02-18 16:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 16:00 RFC on implementation adding buttons beside headings pareto optimal
2023-02-18 16:01 ` pareto optimal [this message]
2023-02-20 19:17 ` Bruno Barbier
2023-02-19 11:04 ` Ihor Radchenko
2023-02-19 22:57 ` Samuel Wales
[not found] ` <292424133.47705.1676856972523@fidget.co-bxl>
2023-02-20 13:23 ` Ihor Radchenko
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=418353827.205931.1676736087884@fidget.co-bxl \
--to=pareto.optimal@mailfence.com \
--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).