From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2DvNMn328GMPiQAAbAwnHQ (envelope-from ) for ; Sat, 18 Feb 2023 17:02:05 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id wALyMX328GOt5AAAG6o9tA (envelope-from ) for ; Sat, 18 Feb 2023 17:02:05 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8403C39390 for ; Sat, 18 Feb 2023 17:02:05 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=mailfence.com header.s=20210208-e7xh header.b=d+K9Izz1; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=quarantine) header.from=mailfence.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1676736125; a=rsa-sha256; cv=none; b=El0/m8FeuxVM7dorV+04MBNAzhBRKbOedjIJBrfM1YYT7GOaVG89Vr2SygU2uEnDKQc/Bg WtUv3CBvH/FmbebllTE9PslEVD/pM2dQiSnu1k151TcoRjwV9xIH7qTkzB04XR5KB5SHk5 ZXmZMQ8NXSc3/3rvUbih7QPOolFb+yvg36R2BAq63up23mUCR940C2OQRO2P48kuRHe0m9 jjgslN5Mb+h62cDz8ixkXIwON7ENbDLGk/9hAxVcSAIwOR0Q6LWEObBT/DMWojfqsCzBTD POFQ8xvn5iVDEQA4FMAcvD3FNHGPRCdIQWnSNHXG43JnOUDJZlEGFPdzMMCaPw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=mailfence.com header.s=20210208-e7xh header.b=d+K9Izz1; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=quarantine) header.from=mailfence.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676736125; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=l8GWYUdlDkd1+k86Eji2VsIq421jQzwg4morKbOFGzg=; b=HyeTYrSh/vNtlDP0jFYBoz3kPnEU5n+qX/iuBaFLWfP1AgOoF/GIGtz5mwkghmw+z8f5q4 iam++NMV8AOozioU30EuZfzC9Wigm5/o14UZxzlLMmGjLCXWE4V/qHcKv904NbO8gI2tMi jI+iE3EIOU4sXWV80afna4NWsnMgZoLNp8IJ6ujXda1TcrLwi99Immo55BdOqxI+9968/1 G+t5VsDJqfLjyNHD20d8Xm2S2CFLnP0iZ5QEDhmnW5hxwnMu6uO2UdYKx6TgR2kydoE8gw yM4RmhqaNoIrRVkCJDv+cOzd4AwdWM2edkeFFVsfTTAPbTZdfAjN61Y8E5yQWA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pTPer-0007CC-Da; Sat, 18 Feb 2023 11:01:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTPea-00070R-3n for emacs-orgmode@gnu.org; Sat, 18 Feb 2023 11:01:36 -0500 Received: from wilbur.contactoffice.com ([212.3.242.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTPeX-0001ul-V3 for emacs-orgmode@gnu.org; Sat, 18 Feb 2023 11:01:35 -0500 Received: from fidget.co-bxl (fidget.co-bxl [10.2.0.33]) by wilbur.contactoffice.com (Postfix) with ESMTP id 31B2594D for ; Sat, 18 Feb 2023 17:01:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1676736091; s=20210208-e7xh; d=mailfence.com; i=pareto.optimal@mailfence.com; h=Date:From:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type; l=8188; bh=l8GWYUdlDkd1+k86Eji2VsIq421jQzwg4morKbOFGzg=; b=d+K9Izz19XEBOmAmOCF06PKCPJFwusXZ5pfP4pti0EhkKzVWMViEUEupbUoz8aIV 0dLEmoWPImVQUZqXDvrDbd9u8i0hmXzirsNUvN6LWCmg3hoU/kDUGYKbWPnRozd0aKh CApsGFKNSXrSwWdkwTVDfjNkJt6zbSGz7TFJpROAW7WCYphf7lN9QpTQNGD+ZQg+OS1 foFqnCdazq+728RrynOs8LQWPWWyiF4WN5T22VJgzeF9AZ3BnoA0IlJO97YOkSp/+4m A51RTkihCqahs3TYCOL5GI5BVDg9rw0XC86xGYd1MD0heHhOaoZV1isqu7gJD107lBZ T86oQRPH3Q== Date: Sat, 18 Feb 2023 17:01:27 +0100 (CET) From: pareto optimal To: Emacs Orgmode Message-ID: <418353827.205931.1676736087884@fidget.co-bxl> In-Reply-To: <1495820062.205861.1676736033884@fidget.co-bxl> References: <1495820062.205861.1676736033884@fidget.co-bxl> Subject: Re: RFC on implementation adding buttons beside headings MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_205928_80267692.1676736087883" X-Mailer: ContactOffice Mail X-ContactOffice-Account: com:311504211 Received-SPF: pass client-ip=212.3.242.68; envelope-from=pareto.optimal@mailfence.com; helo=wilbur.contactoffice.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Queue-Id: 8403C39390 X-Spam-Score: -11.31 X-Migadu-Spam-Score: -11.31 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-TUID: JLz60TfKkibS ------=_Part_205928_80267692.1676736087883 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I forgot the implementation: ``` (define-button-type 'org-clock-in-button =C2=A0 'follow-link t =C2=A0 'face 'custom-button =C2=A0 'mouse-face 'custom-button-mouse =C2=A0 'action (lambda (b) (org-clock-in))) (define-button-type 'org-clock-out-button =C2=A0 'follow-link t =C2=A0 'face 'custom-button =C2=A0 'mouse-face 'custom-button-mouse =C2=A0 'action (lambda (b) (org-clock-out))) (defun has-clock-in-button () =C2=A0 (s-contains? "Clock In" (nth 4 (org-heading-components)))) =C2=A0(defun has-clock-out-button () =C2=A0 (s-contains? "Clock Out" (nth 4 (org-heading-components)))) (defun pod/add-clock-in-button-to-right-of-heading () =C2=A0 (unless (has-clock-in-button) =C2=A0 (save-excursion =C2=A0 =C2=A0 (org-end-of-line) =C2=A0 =C2=A0 (let ((end-of-line-before-insert (point))) =C2=A0 =C2=A0 =C2=A0 (insert "=C2=A0 =C2=A0 Clock In") =C2=A0 =C2=A0 =C2=A0 (let* ((button-start (+ 4 end-of-line-before-insert)) =09=C2=A0 =C2=A0 (button-end (+ 8 button-start))) =09(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 () =C2=A0 (unless (has-clock-out-button) =C2=A0 (outline-up-heading) =C2=A0 ;; (remove-clock-in-button) =C2=A0 (save-excursion =C2=A0 =C2=A0 (org-end-of-line) =C2=A0 =C2=A0 (let ((end-of-line-before-insert (point))) =C2=A0 =C2=A0 =C2=A0 (insert "=C2=A0 =C2=A0 Clock Out") =C2=A0 =C2=A0 =C2=A0 (let* ((button-start (+ 4 end-of-line-before-insert)) =09=C2=A0 =C2=A0 (button-end (+ 9 button-start))) =09(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-ri= ght-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 = wrote: Hi all! I've recently been playing with emacs on Android and wanted an easier way t= o clock in. My idea was to put buttons beside org headings that are TODO items. I do th= is by: - removing clocking buttons on heading if present, then adding a clock in b= utton on=C2=A0'org-after-todo-state-change-hook` - removing clocking buttons on heading if present, then adding a clock out = button on=C2=A0'org-clock-in-hook - removing clocking buttons on heading if present, then adding a clock in b= utton on=C2=A0'org-clock-out-hook Well, the removing part isn't quite implemented yet but that's the idea. Ot= herwise 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 bu= tton where I wanted was to insert some blank space after the heading. Is th= at 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 frie= nds 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/ ------=_Part_205928_80267692.1676736087883 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
I forgot the implementati= on:

```
(define-button-type 'org-clock-in= -button
  'follow-link t
  'face 'custom-butt= on
  'mouse-face 'custom-button-mouse
  'acti= on (lambda (b) (org-clock-in)))

(define-button-typ= e 'org-clock-out-button
  'follow-link t
  'f= ace 'custom-button
  'mouse-face 'custom-button-mouse
<= div>  'action (lambda (b) (org-clock-out)))

(= defun has-clock-in-button ()
  (s-contains? "Clock In" (nth = 4 (org-heading-components))))

 (defun has-clo= ck-out-button ()
  (s-contains? "Clock Out" (nth 4 (org-head= ing-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)))
&nb= sp;     (insert "    Clock In")
   =   (let* ((button-start (+ 4 end-of-line-before-insert))
=09    (button-end (+ 8 butto= n-start)))
=09(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 ()
&= nbsp; (unless (has-clock-out-button)
  (outline-up-heading)<= /div>
  ;; (remove-clock-in-button)
  (save-excursi= on
    (org-end-of-line)
    (let (= (end-of-line-before-insert (point)))
      (insert= "    Clock Out")
      (let* ((button-s= tart (+ 4 end-of-line-before-insert))
=09    (button-end (+ 9 button-start)))
=09(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-o= ut-hook #'pod/add-clock-in-button-to-right-of-heading)
```<= br>
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 i= dea was to put buttons beside org headings that are TODO items. I do this b= y:

- removing clocking buttons on heading if prese= nt, then adding a clock in button on 'org-after-todo-state-change-hook= `

- removing clocking buttons on heading if presen= t, 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. Otherwi= se what I'll paste below is a working implementation.

<= div>I'm new to using buttons and emacs and I found the only way to place th= e button where I wanted was to insert some blank space after the heading. I= s that expected and best practice or is there some other way to do it?

Would this be something useful in core org-mode? I kno= w 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/
<= /blockquote>
------=_Part_205928_80267692.1676736087883--