Re: [PATCH] org-capture.el: Allow `(here)' as a template target

2023-06-23 Thread Tim Visher
On Fri, Jun 23, 2023 at 6:53 AM Ihor Radchenko  wrote:

> Tim Visher  writes:
>
> > I've attached a small follow up `worg` patch to hopefully clarify the
> > changelog section of the commit message going forward for other
> > contributors.
>
> Thanks!
> Applied, onto master, with amendments:
>
> 1. I removed "Note", converting into normal sentence. Note is redundant.
> 2. I added reference to GNU standards, explaining what ChangeLogs are.
> https://git.sr.ht/~bzg/worg/commit/ac865c20


Fantastic! Thanks for all your help, Ihor! TTFN!


Re: [PATCH] org-capture.el: Allow `(here)' as a template target

2023-06-22 Thread Tim Visher
On Thu, Jun 22, 2023 at 6:13 AM Ihor Radchenko  wrote:

> Tim Visher  writes:
>
> > Will do! I've attached a prospective patch file but I'm not sure I follow
> > what you mean by 'add all the necessary changelog entries to the final
> > commit
> > message'. Looking at this commit
> > <
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=294a4d2fe21ffcdc1acbbafed1bfc69a1ece7d13
> >
> > I'm guessing that I should have an `* …` entry for every file except
> > `etc/NEWS` that I changed so I've done that but please do let me know if
> > that was the wrong interpretation. :)
>
> Applied, onto main, amending the changelog entries.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=bea9fca18
>
> Should be an entry for every file, including ORG-NEWS, followed by more
> general comments.
>

卵 亂 !!! :)

I've attached a small follow up `worg` patch to hopefully clarify the
changelog section of the commit message going forward for other
contributors.


0001-org-contribute.org-Clarify-files-to-include-in-chang.patch
Description: Binary data


Re: [PATCH] org-capture.el: Allow `(here)' as a template target

2023-06-21 Thread Tim Visher
On Wed, Jun 21, 2023 at 11:54 AM Ihor Radchenko  wrote:

> Tim Visher  writes:
>
> >> Also, may you update the docstring of `org-capture-templates'
> >
> >
> > Good catch! This has been done in patch 0004 now. Look good?
>
> Yup.
>



>> "10.1.3.1 Template elements" section of Org manual?
> >
> > I'm confused about what you're referring to here. Isn't that what 0002
> does?
>
> Yes, it does. I saw it, then noticed the missing `org-capture-templates'
> docstring update, and somehow deduced that manual must be missing
> :facepalm:
>




> > Again, happy to squash and provide a single complete patch once we're all
> > done the review. Thanks again, Ihor! :)
>
> Please, also add all the necessary changelog entries to the final commit
> message.
>

Will do! I've attached a prospective patch file but I'm not sure I follow
what you mean by 'add all the necessary changelog entries to the final
commit
message'. Looking at this commit
<https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=294a4d2fe21ffcdc1acbbafed1bfc69a1ece7d13>
I'm guessing that I should have an `* …` entry for every file except
`etc/NEWS` that I changed so I've done that but please do let me know if
that was the wrong interpretation. :)


0001-org-capture.el-Allow-here-as-a-template-target 3.patch
Description: Binary data


Re: [PATCH] org-capture.el: Allow `(here)' as a template target

2023-06-21 Thread Tim Visher
On Wed, Jun 21, 2023 at 6:29 AM Ihor Radchenko  wrote:

> Tim Visher  writes:
>
> > I've now created patches for updating the manual and NEWS file. Let me
> know
> > how they look!
>
> Thanks! The patches look good, and the commit messages look excellent.
>

٩( ᐛ )و


> You could, however, squash the patches together


Absolutely! Will do once we've approved the whole change. I will use the
commit message of 0001 for the whole patch.


> Also, may you update the docstring of `org-capture-templates'


Good catch! This has been done in patch 0004 now. Look good?


> "10.1.3.1 Template elements" section of Org manual?
>

I'm confused about what you're referring to here. Isn't that what 0002 does?

```
$ cat 0002-squash-doc-org-manual.org-Add-documentation-for-here.patch
>From 4b4bf944129635637c6fd57076f1c963b4c27bf6 Mon Sep 17 00:00:00 2001
From: Tim Visher 
Date: Tue, 20 Jun 2023 15:11:58 -0400
Subject: [PATCH 2/4] squash! doc/org-manual.org: Add documentation for
 `(here)` target

---
 doc/org-manual.org | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 21582fe8e..76131f110 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -7946,6 +7946,10 @@ Now lets look at the elements of a template
definition.  Each entry in

 File to the entry that is currently being clocked.

+  - =(here)= ::
+
+The position of =point=.
+
   - =(function function-finding-location)= ::

 Most general way: write your own function which both visits the
--
2.40.1
```

Again, happy to squash and provide a single complete patch once we're all
done the review. Thanks again, Ihor! :)


0002-squash-doc-org-manual.org-Add-documentation-for-here.patch
Description: Binary data


0003-squash-etc-ORG-NEWS-Add-entry-for-here-capture-templ.patch
Description: Binary data


0004-squash-Update-docstring-of-org-capture-templates.patch
Description: Binary data


0001-org-capture.el-Allow-here-as-a-template-target 2.patch
Description: Binary data


Re: [PATCH] org-capture.el: Allow `(here)' as a template target

2023-06-20 Thread Tim Visher
On Fri, May 12, 2023 at 12:32 PM Ihor Radchenko  wrote:

> Tim Visher  writes:
>
> > I think this should likely involve an update to the manual but I don't
> want
> > to bother doing that unless the basic approach is approved.
>
> LGTM.
>

Sorry this took me forever to get to.

I've now created patches for updating the manual and NEWS file. Let me know
how they look!


0001-org-capture.el-Allow-here-as-a-template-target 2.patch
Description: Binary data


0003-etc-ORG-NEWS-Add-entry-for-here-capture-template-tar.patch
Description: Binary data


0002-doc-org-manual.org-Add-documentation-for-here-target.patch
Description: Binary data


[PATCH] org-capture.el: Allow `(here)' as a template target

2023-05-12 Thread Tim Visher
Hi Everyone,

I think this should likely involve an update to the manual but I don't want
to bother doing that unless the basic approach is approved.

-

>From eccc3f8f805c38b1de55fc8ad60c67a87e2feea4 Mon Sep 17 00:00:00 2001
From: Tim Visher 
Date: Fri, 12 May 2023 11:32:21 -0400
Subject: [PATCH] org-capture.el: Allow `(here)' as a template target

* lisp/org-capture.el (org-capture-set-target-location): Allow `(here)' as
a template
target in addition to `here'.

Templates had no user accessible way to target the current location
directly from a capture template. Attempting to directly utilize the
behavior accessible through a 0 prefix arg exposed the inconsistent
treatment of the `:target` property in
`org-capture`. `org-capture-set-target-location` understood that it
could be both a symbol and a list, while `org-capture` itself required
it to be a list through its use of `car`.

This change opts to make `org-capture-set-target-location` more
liberal in what it accepts rather than making `org-capture` agree that
targets can be lists. This is because the manual implies, especially
in the `(clock)' entry, that targets are expected to be lists even if
they are meant as specific points.

TINYCHANGE
---
 lisp/org-capture.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d4311dd20..f14e95c5c 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -991,7 +991,8 @@ Store them in the capture property list."
   (let ((target-entry-p t))
 (save-excursion
   (pcase (or target (org-capture-get :target))
- (`here
+ ((or `here
+ `(here))
  (org-capture-put :exact-position (point) :insert-here t))
  (`(file ,path)
  (set-buffer (org-capture-target-buffer path))
-- 
2.40.1


0001-org-capture.el-Allow-here-as-a-template-target.patch
Description: Binary data


Re: Can `org-capture` templates be made to result in a sub-heading of the current heading?

2023-05-12 Thread Tim Visher
On Fri, May 12, 2023 at 8:05 AM Ihor Radchenko  wrote:

> Tim Visher  writes:
> > Can `org-capture` templates be made to result in a sub-heading of the
> > current heading?
>
> Just use target `here' (as symbol).
>

Thanks for the suggestion, Ihor.

Do you have an example of this actually working? I'm on `Org mode version
9.6.5` which looks to be the latest available from GNU ELPA and there seems
to be a dispute between `org-capture-set-target-location` which understands
<https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org-capture.el?id=30b790f42bd0de95ca15d927e27b9125b6549043#n993>
that the result of `(org-capture-get :target)` can return a symbol rather
than a list vs. `org-capture` itself which assumes
<https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org-capture.el?id=30b790f42bd0de95ca15d927e27b9125b6549043#n719>
that target will _always_ be a list.

My testing code:

```
(timvisher--comment
 ;; Context
 (defmacro timvisher--comment
 ( _)
   nil)

 (defmacro wcb (buffer  body)
   `(with-current-buffer ,buffer
  ,@body))

 ;; Demo code
 (setq org-capture-templates
   '(("1" "1" entry here "* 1")
 ("2" "2" entry (here) "* 2")))

 ;; Fails with `Capture template ‘1’: Wrong type argument: listp, here`
 ;; because of `… (car (org-capture-get :target)) …`
 (wcb "todo.org"
  (org-capture nil "1"))

 ;; Fails with `Invalid capture target specification: (here)` because
 ;; `(pcase (or target (org-capture-get :target)) …)` doesn't have a case
 ;; for `(here)`
 (wcb "todo.org"
  (org-capture nil "2"))
 )
```


Re: Can `org-capture` templates be made to result in a sub-heading of the current heading?

2023-05-11 Thread Tim Visher
On Thu, May 11, 2023 at 9:05 AM Tim Visher  wrote:

> On Thu, May 11, 2023 at 8:42 AM Tim Visher  wrote:
>
>> On Wed, May 10, 2023 at 5:04 PM Tim Visher  wrote:
>>
>>> Can `org-capture` templates be made to result in a sub-heading of the
>>> current heading?
>>>
>>> So
>>>
>>> ```
>>> * This Week
>>> ** TODO A TODO Item
>>>
>>>[2023-05-05 Fri 10:47]
>>>
>>>A description 
>>> ```
>>>
>>> and I whack my capture keychord and get
>>>
>>> ```
>>> * This Week
>>> ** TODO A TODO Item
>>>
>>>[2023-05-05 Fri 10:47]
>>>
>>>A description
>>> *** [2023-05-10 Wed 17:02]
>>>
>>> [2023-05-10 Wed 17:02]
>>>
>>> 
>>> ```
>>>
>>
>> It's worth noting that with a capture template like
>>
>> ```
>> ("twj" "TODO Work TODO Journal" entry
>>  (file+headline "~/Documents/todo.org" "Inbox")
>>  "* %U
>>
>>%U
>>
>>%?")
>> ```
>>
>> If I do the usual `M-0 M-x org-capture` with point in the original spot
>> it behaves exactly as I want it to. My goal is to get it to behave that way
>> just by invoking the capture template.
>>
>
> OK after poking around in `org-capture-set-target-location` I think I have
> this sorted. Please let me know if I'm doing something obviously silly. :)
>
> ```
> (defun timvisher--org-capture-sub-heading-insertion-point
> ()
>   (insert "\n")
>   (forward-char)
>   (org-capture-put :exact-position (point) :insert-here t))
>
> ;; Embedded in the capture templates list
> ("twj" "TODO Work TODO Journal" entry
>  (function timvisher--org-capture-sub-heading-insertion-point)
>  "* %U
>
>   %U
>
>   %?")
> ```
>

Minor correction. I need to both insert a newline _and *leave*_ point where
it was or I don't get a sub-heading at the proper level (the current level
of the previous journal entry). If I don't insert the newline then
cancelling the entry also pulls the next heading up into the text of the
current heading.

```
(defun timvisher--org-capture-sub-heading-insertion-point
()
  (insert "\n")
  (org-capture-put :exact-position (point) :insert-here t))
…
```

-- Tim Visher


Re: Can `org-capture` templates be made to result in a sub-heading of the current heading?

2023-05-11 Thread Tim Visher
On Thu, May 11, 2023 at 8:42 AM Tim Visher  wrote:

> On Wed, May 10, 2023 at 5:04 PM Tim Visher  wrote:
>
>> Can `org-capture` templates be made to result in a sub-heading of the
>> current heading?
>>
>> So
>>
>> ```
>> * This Week
>> ** TODO A TODO Item
>>
>>[2023-05-05 Fri 10:47]
>>
>>A description 
>> ```
>>
>> and I whack my capture keychord and get
>>
>> ```
>> * This Week
>> ** TODO A TODO Item
>>
>>[2023-05-05 Fri 10:47]
>>
>>A description
>> *** [2023-05-10 Wed 17:02]
>>
>> [2023-05-10 Wed 17:02]
>>
>> 
>> ```
>>
>
> It's worth noting that with a capture template like
>
> ```
> ("twj" "TODO Work TODO Journal" entry
>  (file+headline "~/Documents/todo.org" "Inbox")
>  "* %U
>
>%U
>
>%?")
> ```
>
> If I do the usual `M-0 M-x org-capture` with point in the original spot it
> behaves exactly as I want it to. My goal is to get it to behave that way
> just by invoking the capture template.
>

OK after poking around in `org-capture-set-target-location` I think I have
this sorted. Please let me know if I'm doing something obviously silly. :)

```
(defun timvisher--org-capture-sub-heading-insertion-point
()
  (insert "\n")
  (forward-char)
  (org-capture-put :exact-position (point) :insert-here t))

;; Embedded in the capture templates list
("twj" "TODO Work TODO Journal" entry
 (function timvisher--org-capture-sub-heading-insertion-point)
 "* %U

  %U

  %?")
```

The key was finding that it wasn't enough to merely move point to the
proper location. I _also_ needed to call `org-capture-put`. The docs on
this subject are a little misleading, IMHO.

‘(function function-finding-location)’
>  Most general way: write your own function which both visits
>  the file and moves point to the right location.


Empirically it seems like you have to visit the file, move point to the
right location, _and_ call `org-capture-put`.

-- Tim Visher


Re: Can `org-capture` templates be made to result in a sub-heading of the current heading?

2023-05-11 Thread Tim Visher
On Wed, May 10, 2023 at 5:04 PM Tim Visher  wrote:

> Can `org-capture` templates be made to result in a sub-heading of the
> current heading?
>
> So
>
> ```
> * This Week
> ** TODO A TODO Item
>
>[2023-05-05 Fri 10:47]
>
>A description 
> ```
>
> and I whack my capture keychord and get
>
> ```
> * This Week
> ** TODO A TODO Item
>
>[2023-05-05 Fri 10:47]
>
>A description
> *** [2023-05-10 Wed 17:02]
>
> [2023-05-10 Wed 17:02]
>
> 
> ```
>

It's worth noting that with a capture template like

```
("twj" "TODO Work TODO Journal" entry
 (file+headline "~/Documents/todo.org" "Inbox")
 "* %U

   %U

   %?")
```

If I do the usual `M-0 M-x org-capture` with point in the original spot it
behaves exactly as I want it to. My goal is to get it to behave that way
just by invoking the capture template.


Can `org-capture` templates be made to result in a sub-heading of the current heading?

2023-05-10 Thread Tim Visher
Hey everyone,

Can `org-capture` templates be made to result in a sub-heading of the
current heading?

So

```
* This Week
** TODO A TODO Item

   [2023-05-05 Fri 10:47]

   A description 
```

and I whack my capture keychord and get

```
* This Week
** TODO A TODO Item

   [2023-05-05 Fri 10:47]

   A description
*** [2023-05-10 Wed 17:02]

[2023-05-10 Wed 17:02]


```

I have a tendency to make these items for longer running tasks that I want
to keep a journal on. The visibility cycling makes it easier to see my
progress over time.

Thanks in advance!

-- Tim Visher


Re: Automatically use Heading Content as EXPORT_FILE_NAME?

2022-04-26 Thread Tim Visher
On Tue, Apr 26, 2022 at 11:54 AM Tim Visher  wrote:

> I'm currently going to hack around it I think by simply making a function
> that updates the EXPORT_FILE_NAME property with the current heading text.
>

That's something like

```
(defun timvisher-org-set-export_file_name-property-to-heading-text
()
  (interactive)
  (org-set-property
   "EXPORT_FILE_NAME"
   (let ((stripped-heading
  (replace-regexp-in-string
   "[^-A-Za-z0-9_.~#+ ]"
   ""
   (substring-no-properties (org-get-heading t t t t)
 (substring-no-properties
  stripped-heading
  0
  (min (length stripped-heading) 250)
```


Automatically use Heading Content as EXPORT_FILE_NAME?

2022-04-26 Thread Tim Visher
Hello Everyone,

Is  there a way to automatically use the text content of the current
Heading as the EXPORT_FILE_NAME? AFAICT there isn't.

I tend to do most of my Org writing in a few 'mono files' (like todo.org or
wiki.org). I then set my export options to default to subtree and visible
contents etc.

The resulting file is always named after the whole mono file though. Given
my usage pattern it would be awesome if it instead could default to the
current heading text.

Is that something others would be interested in? I'm currently going to
hack around it I think by simply making a function that updates the
EXPORT_FILE_NAME property with the current heading text.

Thanks in advance!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: frustrations

2021-12-01 Thread Tim Visher
Hi Jan,

On Wed, Dec 1, 2021 at 7:58 AM Eric S Fraga  wrote:

> On Wednesday,  1 Dec 2021 at 13:21, Jan Ulrich Hasecke wrote:
> > How do you configure your emacs using current versions like org 9.5 but
> > at the same time avoiding problems with incompatible packages or newly
> > introduced bugs?
>
> …
>
> Avoiding problems with incompatible packages or new bugs is impossible,
> however.  The solution is to avoid upgrade-itis and only upgrade when
> necessary.  Although I track org from git, I don't update all the time
> and only do so when I know I will have some time to deal with any
> repercussions.  (like today where I upgraded both Emacs and org because
> I know I have no immediate deadlines)
>
> Most other packages, I seldom upgrade if ever.
>

I just wanted to quickly second this. The old saying "If it ain't broke,
don't fix it." is evergreen.

The other thing I'll say though is that so long as you use the `~/.emacs.d`
or `~/.config/emacs` it's very easy to place the entirety of your emacs
config under source control. The key thing to do here is to _check in_ your
package dependencies (`elpa` directory in my case). That way whenever you
upgrade a package it's very easy to revert to a known working state if you
don't have time to work through the incompatibilities.

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: how to document/comment a complex org table formula

2021-07-05 Thread Tim Visher
On Mon, Jul 5, 2021 at 10:14 AM Eric S Fraga  wrote:

> Sorry; I cannot help you directly.
>
> My rule of thumb is that if formulas are getting too complex to
> understand/recall clearly, it's time to use a proper programming
> language instead.  The nice thing about org is you can have tables as
> inputs to and outputs of src blocks...
>
> My papers often have awk source blocks that process tables to generate
> statistics for some (numerical) experiments.
>
> Spreadsheets, org tables being an example of such, are brilliant tools
> for simple calculations but are pretty much "write only programming
> languages".
>

I had never heard of using an org table as input into a source block.
That's really interesting.

The OP also poses an interesting idea that I have occasionally wanted. I
have generally accomplished this by simply including the documentation
above or below the table. In other words just having human text around it
that says 'This =formula= bit is because of X'.

But the idea of a multiline TBLFM syntax seems to be already be almost
supported. I was mildly shocked to find that this mostly works

```
|---+---|
| a | 1 |
| b | 3 |
|---+---|
|   | 4 |
#+TBLFM: @2$2=@-1*3
#+TBLFM: @3$2=vsum(@I..II)
```

Note that I don't need the usual `::` separation between formulas. Where it
breaks down is that I can't seem to reevaluate the whole table's formula by
whacking `C-u C-c C-c` anymore and, obviously, there's no syntax for adding
comments. Also I doubt that I'd be able to use any of org's keys for
editing formulas. I wonder how hard it would be to extend org's
understanding of the TBLFM to allow for this kind of syntax.

Once you had it then adding a comment character to it should be very simple.

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: Failure to resolve internal links on ox-html export?

2021-06-20 Thread Tim Visher
On Fri, Jun 18, 2021 at 6:22 PM Tim Cross  wrote:

>
> Tim Visher  writes:
>
> > Hi Juan Manuel,
> >
> > On Fri, Jun 11, 2021 at 2:31 PM Juan Manuel Macías <
> maciasch...@posteo.net> wrote:
> >
> >  Try setting this variable to non-nil:
> >
> >  (setq org-export-with-broken-links t)
> >
> > Thanks for the tip here! This is definitely close to what I want. I
> think I'm going to need to code up something additional though in that none
> of the
> > default options (mark or ignore) are really the behavior that I want.
> >
> > - mark: I don't like the way the text comes out here. I don't want to
> have BROKEN LINK in the exported text at all.
> > - ignore: I don't like how the text of the link simply disappears in
> this case.
> >
> > What I really want is something that keeps the link text but drops the
> link, essentially converting it into plain text (or stylized text if the
> link text is in
> > markup).
> >
> > I'll have to play around with how to do that.
>
> Although I've never used them, I think export filters sound like they
> might be what you want. Have a look at the Advanced Export configuration
> section of the manual and how to define export filters. You should be
> able to define an org-export-filter-link-function that will tranform
> links into just the title text from the original link.
>

Thanks, Tim! I'll check them out. I hadn't heard of them before.


Re: Failure to resolve internal links on ox-html export?

2021-06-18 Thread Tim Visher
Hi Juan Manuel,

On Fri, Jun 11, 2021 at 2:31 PM Juan Manuel Macías 
wrote:

> Try setting this variable to non-nil:
>
> (setq org-export-with-broken-links t)
>

Thanks for the tip here! This is definitely close to what I want. I think
I'm going to need to code up something additional though in that none of
the default options (mark or ignore) are really the behavior that I want.

- mark: I don't like the way the text comes out here. I don't want to have
BROKEN LINK in the exported text at all.
- ignore: I don't like how the text of the link simply disappears in this
case.

What I really want is something that keeps the link text but drops the
link, essentially converting it into plain text (or stylized text if the
link text is in markup).

I'll have to play around with how to do that.

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Failure to resolve internal links on ox-html export?

2021-06-11 Thread Tim Visher
Hi Everyone,

I'd like to be able to link to various areas of a large wiki file I
maintain for when I'm looking at an entry in emacs. However, I will often
email exported subtrees and when I do that if I have a link to a heading
that's outside the current subtree it fails with a `user-error: Unable to
resolve link: …`, I assume because the export tree doesn't contain that
heading.

Is there any way to tell the exporter to simply make those into plain text
_or_ to simply ignore the error?

Thanks in advance!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: [PATCH] org-mac-link.el: Change homepage.

2021-06-01 Thread Tim Visher
On Mon, May 31, 2021 at 5:20 PM Aimé Bertrand 
wrote:

> would like to move the homepage.
> See attached patch. Thanx.
>

I looked at the patch which moves from sourcehut to gitlab. LGTM. :


Re: Refiling All 'Terminal TODO State' Entries to a Particular Heading

2021-05-12 Thread Tim Visher
Hi Everyone,

I found that my timvisher-org-refile-done-entries had a bug where it could
skip entries if the org buffer had consecutive DONE/CANCELLED entries. I
believe this is because of this quote from the manual:

After evaluation, Org moves point to the end of the line that was just
processed. Search continues from that point forward. This may not always
work as expected under some conditions, such as if the current sub-tree was
removed by a previous archiving operation. In such rare circumstances, Org
skips the next entry entirely when it should not. To stop Org from such
skips, make FUNC set the variable ‘org-map-continue-from’ to a specific
buffer position.

I've been doing some experimentation around how to fix this:
Attempt 1

This feels like the simplest and most naive approach:

(defun timvisher-org-refile-done-entry-position
()
  (save-excursion
(goto-char (point-min))
(- (re-search-forward "^\\* Done") 6)))

(defun timvisher-org-refile-done-entry
()
  (org-refile nil
  (current-buffer)
  (list "* Done"
(buffer-file-name)
nil
(timvisher-org-refile-done-entry-position

(defun timvisher-org-refile-done-entries
()
  (interactive)
  (while (< 0 (length (org-map-entries #'timvisher-org-refile-done-entry
   "LEVEL=2/+DONE|+CANCELLED"
   nil
   'archive)

Here we're literally just doing the org-map-entries operation forever until
the operation finds nothing to operate on.

I worry about infinite loops and all that here though. It also just seems,
well, a little brute force.
Attempt 2

(defun timvisher-org-refile-done-entry
(point)
  (let ((done-entry-position (timvisher-org-refile-done-entry-position)))
(when (< done-entry-position point)
  (error (concat "Refile target at %d is located after the Done "
 "entry at %d. Move the Done entry to the bottom "
 "of the file.")
 point
 done-entry-position))
(goto-char point)
(org-refile nil
(current-buffer)
(list "* Done"
  (buffer-file-name)
  nil
  (timvisher-org-refile-done-entry-position)

(defun timvisher-org-refile-done-entries
()
  (interactive)
  (seq-map #'timvisher-org-refile-done-entry
   (reverse (org-map-entries #'point
 "LEVEL=2/+DONE|+CANCELLED"
 nil
 'archive

Here we're recognizing that if we could process the entries in reverse then
we'd never have to worry about an entry moving from underneath us as we
refile.

This also seems silly:

   1. I'm sure there's a function already that just returns me the matching
   entries for a given match search. Using the mapping API for seems incorrect.
   2. It requires that the Done entry be below all possible targets which
   I'd rather not require. My Done entry is typically above my deferred
   entries and I want to be able to mark deferred entries as cancelled or done
   and have this work properly.

Overall I actually like this attempt less than the first one.
Attempt 3

I'm convinced that there must be something I can do with the
org-map-continue-from var but I'm having a lot of trouble grokking how to
use it properly.

My initial attempt looks like this:

(defun timvisher-org-refile-done-entry
()
  (let ((entry-begin-point (point)))
(org-refile nil
(current-buffer)
(list "* Done"
  (buffer-file-name)
  nil
  (timvisher-org-refile-done-entry-position)))
(setq org-map-continue-from entry-begin-point)))

(defun timvisher-org-refile-done-entries
()
  (interactive)
  (org-map-entries #'timvisher-org-refile-done-entry
   "LEVEL=2/+DONE|+CANCELLED"
   nil
   'archive))

The idea being that if I do in fact refile an entry I'd actually like the
'search to continue' from where it just was. This 'works' in that it
successfully refiles all the entries even if they're consecutive but it
also manages to get into an infinite loop because, AFAICT, it ignores the
'archive skipping somehow. I've spent some time in the debugger and I can't
figure out yet why it does that.

Any tips on how I might use this variable to achieve my goals?

Thanks in advance!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: How to use `open` to handle `message:*` links on macOS

2021-05-06 Thread Tim Visher
On Thu, May 6, 2021 at 1:04 PM Alexander Adolf <
alexander.ad...@condition-alpha.com> wrote:

>
> Tim Visher  writes:
>
> > [...]
> >
> > One of these days though I'm going to break the habit and move email
> > directly into Emacs. :)
>
> I was in the exact same situation as you until about half a year ago,
> which was when I decided to (finally) act on my "move email to emacs"
> task.
>
> Coincidentally I have recently released a blog post covering some of the
> basic aspects of planning the switch:
>
> https://condition-alpha.com/blog/?p=1792
>
> …
>
> The smallest, and most isolated task is perhaps configuring msmtp for
> sending mail; so why not start with that?
>
> …
>
> If you start a big all-in-one migration, and it fails, you're left with
> a big mess. Thus, doing things step-by-step with an option to revert
> each step if it doesn't work, is crucial, too.
>

Great advice and info all around! Thanks so much. :)


Refiling All 'Terminal TODO State' Entries to a Particular Heading

2021-05-06 Thread Tim Visher
Hi Everyone,

Partly because I think it's neat and partly to ask for ways that I could
improve it I figured I'd share my latest little snippet of org elisp with
the list.

I maintain my primary TODO list as an org file with top-level headings like *
This Week, * Delegated, * Scheduled, * Deferred, etc. These all contain
TODOs or potential TODOs.

Anything I intend to work on near term I refile into * This Week and that's
then the primary heading that I'm burning down throughout my day.

I do weekly reflection/projections and 6 week reflection/projections. When
I do a weekly reflection I go through another heading * Done to remind
myself what I accomplished in the past week. When I do a 6 week
reflection/projection I review the Done heading one more time and then I
refile all the entries currently there into an * Archive heading. Then
every now and then I actually archive entries in Archive into an
*.org_archive file. * Done and * Archive are both tagged with ARCHIVE.

In an effort to start automating some of this effort I wrote the following
elisp to refile all the Level 2 entries to the Done heading:

(defun timvisher-org-refile-done-entry-position
()
  (save-excursion
(goto-char (point-min))
(re-search-forward "^\\* Done")))

(defun timvisher-org-refile-done-entry
()
  (org-refile nil
  (current-buffer)
  (list "* Done"
(buffer-file-name)
nil
(timvisher-org-refile-done-entry-position

(defun timvisher-org-refile-done-entries
()
  (interactive)
  (length
   (org-map-entries #'timvisher-org-refile-done-entry
"LEVEL=2/+DONE|+CANCELLED"
nil
'archive)))

I'm doing Level 2 only because for long running projects I tend to have a
single Level 2 heading with many subheadings representing the project's
breakdown and I don't want them to be refiled out of the project.

Opportunities for improvement would be:

   1. Is there a better way to find the * Done entry than searching for it
   every time?
   2. Am I using org-refile correctly there? It's functional but it also
   seems needlessly complicated.

Hope this finds you all well. :)

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: [PATCH]: Add elisp snippet to worg/org-contrib/org-mac.org

2021-05-03 Thread Tim Visher
On Mon, May 3, 2021 at 8:58 AM Bastien  wrote:

> Tim Visher  writes:
>
> > Here's a quick patch that fixes that up:
>
> Applied, thanks.  If you want to contribute more to Worg, please
> send me the username you want in private and I'll create an account
> for you on code.orgmode.org.
>

Thanks for the apply! :)


Re: [PATCH]: Add elisp snippet to worg/org-contrib/org-mac.org

2021-05-03 Thread Tim Visher
Hi Bastien,

On Mon, May 3, 2021 at 12:05 AM Bastien  wrote:

>
> Tim Visher  writes:
>
> > At the recommendation of Tim Cross I've prepared a patch to worg to
> > include the elisp that I recently sent to the list that I've been
> > using to create TODO items based on the currently selected macOS
> > Mail.app message.
> >
> > Let me know if there's anything I can do to help get it applied.
>
> Applied in Worg, thanks a lot.
>

Thanks for the quick apply!

I'm surprised but I failed to notice that I never actually finished the
hyperlink to the new org-mac-mail-link.org file from org-mac.org. I only
saw it when I went to the site <https://orgmode.org/worg/org-mac.html> to
check out the fruits of our labors. (-‸ლ)

Here's a quick patch that fixes that up:

>From 5a363a927f67d2c8571085110ce336872a073fac Mon Sep 17 00:00:00 2001
From: Tim Visher  
Date: Mon, 3 May 2021 08:25:46 -0400
Subject: [PATCH] org-mac: Fix link to org-mac-mail-link from org-mac
---
 org-mac.org | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/org-mac.org b/org-mac.orgindex 2addd5f0..b7c334fd
100644--- a/org-mac.org+++ b/org-mac.org@@ -33,7 +33,7 @@ applications
other than Emacs...
insert it as a hyperlink at point in an org-mode document. Written
by /Anthony Lander/.
-** org-mac-mail-link -- Hyperlink to messages in Mail.app+**
[[file:org-contrib/org-mac-mail-link.org][org-mac-mail-link]] --
Hyperlink to messages in Mail.app
A small elisp file that addresses linking to Mail.app messages
directly via the =org-capture= system. For wider application
support check out [[file:org-contrib/org-mac-link.org][org-mac-link]].--
2.30.1


0001-org-mac-Fix-link-to-org-mac-mail-link-from-org-mac.patch
Description: Binary data


Re: How to use `open` to handle `message:*` links on macOS

2021-05-02 Thread Tim Visher
Hi Alexander,

On Thu, Apr 29, 2021 at 7:38 PM Alexander Adolf <
alexander.ad...@condition-alpha.com> wrote:

> Tim Visher  writes:
>
> > Pairing that with my org-capture TODO Current Mail Template is a dream
> come
> > true. :)
> > [...]
>
> That's interesting how you pull the information from Mail app.
>
> How do you trigger the capture? Do you have to select the message in
> Mail app, then move over to Emacs and trigger the capture there? or do
> you have a way to trigger the Emacs capture from within Mail app?
>
> The next level of productivity could perhaps be to switch to notmuch[1],
> and do all you email from within Emacs. Use yasnippet[2] for composing
> mails. And have snippets be presented to you by company[3]. Just
> saying... ;-)
>
> [1] https://notmuchmail.org/
> [2] http://joaotavora.github.io/yasnippet/
> [3] https://company-mode.github.io/


I do indeed trigger the capture by switching over to Emacs and whacking my
org-capture keybinding (`C-c C`). I have a todo item that's been sitting in
my list for a very long time to figure out how to move my email habits into
emacs but I've never gotten around to it. In this case it's even worse
because the only reason I'm using Mail.app in the first place is because my
work email got moved to an Exchange server so I now don't have a good web
based interface to read mail anymore like my beloved Gmail.

One of these days though I'm going to break the habit and move email
directly into Emacs. :)

Thanks for the tips again!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


[PATCH]: Add elisp snippet to worg/org-contrib/org-mac.org

2021-05-02 Thread Tim Visher
Hello,

At the recommendation of Tim Cross
<https://lists.gnu.org/archive/html/emacs-orgmode/2021-04/msg00813.html> I've
prepared a patch to worg to include the elisp that I recently sent to the
list that I've been using to create TODO items based on the currently
selected macOS Mail.app message.

Let me know if there's anything I can do to help get it applied.

>From d1a7818593aee6bcb6de5c6837c506905a64f723 Mon Sep 17 00:00:00 2001
From: Tim Visher  
Date: Sun, 2 May 2021 16:34:24 -0400
Subject: [PATCH] org-mac: Add org-mac-mail-link section and elisp
---
 org-contrib/org-mac-mail-link.org | 147 ++
 org-mac.org   |   5 +
 2 files changed, 152 insertions(+)
 create mode 100644 org-contrib/org-mac-mail-link.org
diff --git a/org-contrib/org-mac-mail-link.org
b/org-contrib/org-mac-mail-link.orgnew file mode 100644index
..6e7f9c52--- /dev/null+++
b/org-contrib/org-mac-mail-link.org@@ -0,0 +1,147 @@+#+TITLE:
org-mac-mail-link.el -- Create and handle links to the selected
Mail.app message+#+OPTIONS:   ^:{} author:Tim Visher+#+STARTUP: odd++#
This file is released by its authors and contributors under the GNU+#
Free Documentation license v1.3 or later, code examples are released+#
under the GNU General Public License v3 or
later.++[[file:index.org][{Back to Worg's contibutions index}]]++*
Overview++  This code will allow you to capture a TODO item based on
the+  currently selected Mail.app message using =org-capture=.++*
Installation++  You should simply copy the source code from this
document into your+  init file and edit it as you see fit.++* Usage++
Activate =org-capture= however you see fit (=M-x org-capture= works+
just fine) and then whack the keychord you have set up to activate+
the capture template.++* Code++  #+begin_src elisp+
;;+
 ;;; Capture template for the currently selected Mail.app message+
;;++
 (defun org-mac-mail-link-get-selected-message-subject+  ()+
(with-temp-buffer+  (call-process+   "osascript" nil t nil+
   "-e" "tell application \"Mail\" to get subject of item 1 of
(selection as list)")+  (buffer-substring-no-properties
(point-min) (- (point-max) 1++  (defun
org-mac-mail-link-get-selected-message-id+  ()+
(with-temp-buffer+  (call-process+   "osascript" nil t nil+
   "-e" "tell application \"Mail\" to get message id of item 1 of
(selection as list)")+  ;; This additional encoding specifically
of =/= is because Mail.app+  ;; claims to be unable to find a
message if it's ID contains unencoded+  ;; slashes.+
(browse-url-url-encode-chars+   (buffer-substring-no-properties
(point-min) (- (point-max) 1))+   "[/]")))++  (defun
org-mac-mail-link-get-link-string+  ()+(let ((subject
(org-mac-mail-link-get-selected-message-subject))+
(message-id (org-mac-mail-link-get-selected-message-id)))+
(org-link-make-string (format "message:%s" message-id)+
subject)))++  (defun
org-mac-mail-link-get-body-quote-template-element+  ()+(let
((body (setq body (with-temp-buffer+
(call-process+  "osascript" nil t nil+
 "-e" "tell application \"Mail\" to get
content of item 1 of (selection as list)")+
 (buffer-substring-no-properties (point-min) (- (point-max) 1))+
   (format "++,#+begin_quote+  %s+,#+end_quote"+
(string-join+   ;; Remove duplicate empty lines+
(seq-reduce+(lambda (acc next)+
(if (string= next (or (car (last acc)) ""))+  acc+
   (append acc (list next+;;
Indent each line by two spaces for inclusion in the quote+
   (mapcar (lambda (string)+  (let ((string
(string-trim string)))+(if (string= ""
string)+string+
  (format "  %s" string+(split-string
body "\n"))+'())+   "\n"++  (require
'org-capture)++  ;;; You may also wish to use the Customize interface
for this variable+  ;;; which is quite nice.+  (setq
org-capture-templates+;; These 2-item entries are only
necessary if you want to nest the+;; capture template under a
keychord.+'(("t" "TODO")+  ("tc" "TODO Current")+
("tcm" "TODO Current Mail" entry+   ;; If you maintain
your TODO list in a single file this will+   ;; place the
resulting org-capture template expansion under the+   ;;
'Inbox' heading. You may want to modif

Re: How to use `open` to handle `message:*` links on macOS

2021-04-29 Thread Tim Visher
On Thu, Apr 29, 2021 at 3:40 PM Tim Cross  wrote:

>
> Tim Visher  writes:
>
> > Thanks for the tips here. I finally got around to trying them out.
> Here's what I ended up with and it's working perfectly.
> >
> > …
> >
> > Pairing that with my org-capture TODO Current Mail Template is a dream
> come true. :)
> >
> > …
>
> I think this would be great content to add to the worg site. Would you
> be willing to add this, plus a short outline of the issue you needed to
> resolve so that others might benefit from your experience?
>

I'd be happy to if you wouldn't mind shepherding me through the process a
bit. How does one go about "add[ing] to the worg site"? :)


Re: How to use `open` to handle `message:*` links on macOS

2021-04-29 Thread Tim Visher
Hi Diego and Alexander,

Thanks for the tips here. I finally got around to trying them out. Here's
what I ended up with and it's working perfectly.

(defun timvisher-org-link-mac-mail-open-link
(mid _)
  (start-process "open-link" nil "open" (format "message://%%3C%s%%3E"
mid)))

(defun timvisher-org-link-mac-mail-add-message-links
()
  (org-link-set-parameters
   "message" :follow #'timvisher-org-link-mac-mail-open-link))

(eval-after-load 'org
  '(timvisher-org-link-mac-mail-add-message-links))

Pairing that with my org-capture TODO Current Mail Template is a dream come
true. :)

(defun timvisher-org-current-mail-get-selected-message-subject
()
  (with-temp-buffer
(call-process
 "osascript" nil t nil
 "-e" "tell application \"Mail\" to get subject of item 1 of
(selection as list)")
(buffer-substring-no-properties (point-min) (- (point-max) 1

(defun timvisher-org-current-mail-get-selected-message-id
()
  (with-temp-buffer
(call-process
 "osascript" nil t nil
 "-e" "tell application \"Mail\" to get message id of item 1 of
(selection as list)")
(browse-url-url-encode-chars
 (buffer-substring-no-properties (point-min) (- (point-max) 1))
 "[/]")))

(defun timvisher-org-current-mail-get-link-string
()
  (let ((subject (timvisher-org-current-mail-get-selected-message-subject))
(message-id (timvisher-org-current-mail-get-selected-message-id)))
(org-link-make-string (format "message:%s" message-id)
  subject)))

(defun timvisher-org-current-mail-get-body-quote-template-element
()
  (let ((body (setq body (with-temp-buffer
 (call-process
  "osascript" nil t nil
  "-e" "tell application \"Mail\" to get content of
item 1 of (selection as list)")
 (buffer-substring-no-properties (point-min) (-
(point-max) 1))
(format "
  #+begin_quote%s  #+end_quote"
(string-join
 (seq-reduce
  (lambda (acc next)
(if (string= next (or (car (last acc)) ""))
acc
  (append acc (list next
  (mapcar (lambda (string)
(let ((string (string-trim string)))
  (if (string= "" string)
  string
(format "  %s" string
  (split-string body "\n"))
  '())
 "\n"

(setq org-capture-templates
  '(…
("twcm" "TODO Work Current Mail" entry
 (file+headline "~/Dropbox/todo/work.org" "Inbox")
 "* TODO %(timvisher-org-current-mail-get-link-string)
  %U%(timvisher-org-current-mail-get-body-quote-template-element)"
:prepend t :immediate-finish t)
…))

Thanks so much! :)


org-attach-attach in an org-capture template?

2021-04-29 Thread Tim Visher
Hi Everyone,

*TL;DR:* I've recently started using org-capture and I'd like to run
org-attach-attach during the expansion of a few of my templates. Doing so
from a template function seems not to work (meaning a function in a
template string called with %(…)). What's the best way to go about this?
--

I've recently started to explore org-capture and it's pretty great. I'm
interested in having one of my templates search for a file somewhere and,
if it finds one, add it to the current template as an attachment.

My initial test template looks something like:

(defun attach-file
()
  (org-attach-attach (expand-file-name "a file")
 nil
 'cp))

(setq org-capture-templates
  '("T" "TEST" entry
(file+headline "~/x.org" "Inbox")
"* TODO Foo%(attach-file)
  %U"))

The idea being that attach-file would call org-attach-attach if it could
find a file and always expand to nothing.

Upon testing that I see the following (org 9.4.5-g287af2, emacs 27.2 (build
1, x86_64-apple-darwin18.7.0)):

** TODO Foo%![Error: (error bug: org-id-get expects a file-visiting buffer)]
   :PROPERTIES:
   :ID:   05837793-5A4F-42FC-AB50-5165FA7ECC4B
   :END:

   [2021-04-29 Thu 09:52]

If I then call org-attach manually on the resulting entry I can attach a
file fine to it.

I'm aware that I can make the template an elisp function and do the work
all internally. That's probably what I'll start doing presently. But it's a
little annoying that I then need to reimplement org-capture's built-in
template expansion in some way (like %U for the current inactive timestamp).

I also believe I could do this with one of the org-capture hooks but
examining them I didn't see the obvious right one to add my function to. I
would think it would be the org-capture-prepare-finalize-hook and I may
just give that a try. I further assume then that I'd need to to apply the
advice here

and
check for what template I'm in with (plist-get org-capture-plist :key) or
similar.

So my question is whether there's anything I can do to get org-attach-attach to
recognize the file it's in. I'm assuming that when it's expanding it's in a
temporary buffer of some kind which is why it's failing.

All thoughts and advice are most welcome. Thanks in advance! :)

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-04-22 Thread Tim Visher
On Thu, Apr 22, 2021 at 11:36 AM Nicolas Goaziou 
wrote:

> Tim Visher  writes:
>
> > Thanks for the tip. What I'm thinking more is somehow getting the heading
> > pre-output generation, stripping any characters that `org` would consider
> > special (I'm hoping there's already a function that can at least mark
> > 'markup' text in a given org string), and _then_ passing it to whatever
> ox
> > function is responsible for using the title. That way it's as generic as
> it
> > can possibly be.
>
> What format has "heading pre-output generation"? Is a string or is it
> parsed data? The first part of your paragraph sounds like you want to
> rewrite an Org parser.
>
> How do you pass it to ox function responsible for using the title? I.e.,
> who/what is responsible for making the change to the title? Is it the
> user?
>
> You may need to clarify your specifications.
>
> > I confess though that I don't follow exactly what you're talking about
> > defining a temporary export back-end.
>
> In `org-html--build-meta-info' from "ox-html.el", replace the following
>
>   (org-html-plain-text
>(org-element-interpret-data (plist-get info :title)) info)
>
> with
>
>   (org-export-data-with-backend (plist-get info :title)
> (org-export-create-backend
>  :transcoders
>  '((bold . (lambda (_ c _) c))
>(italic . (lambda (_ c _) c
> info)
>
> Now re-evaluate the function `org-html--build-meta-info' and try
> exporting a document to HTML with a title containing bold and italic
> syntax, even nested, e.g.
>
>   #+title: /Some *bold* text/
>
> > Why would that be necessary or beneficial to the end of teaching org
> > how to use only the 'plain text' of a heading for the title in N ox
> > backends?
>
> Adding the function `org-export-strip-syntax below to "ox.el"
>
>   (defun org-export-strip-syntax (data info)
> (org-export-data-with-backend data
>   (org-export-create-backend
>:transcoders
>'((bold . (lambda (_ c _) c))
>  (italic . (lambda (_ c _) c
>   info))
>
> you can now call it from any export back-end whenever its needs to
> remove syntax from a piece of code.
>
> You can also drop the info argument and add it to "org-element.el". But
> it depends on what you want to obtain. Also, some syntax is not obvious
> to strip, as I suggested in my previous message.
>

Awesome! This is a ton of great info. If I decide to bite this off I'll be
sure to reference this. :)


Re: ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-04-22 Thread Tim Visher
On Thu, Apr 22, 2021 at 9:52 AM Nicolas Goaziou 
wrote:

> Tim Visher  writes:
>
> > Awesome. Do you know whether there's an official way to share this sort
> of
> > behavior between ox backends or is it just creating a function and
> calling
> > it from both places or something?
>
> Do you want to remove all markup from some parsed text?
>
> You could define temporary export back-end with
> `org-export-create-backend', and apply it with
> `org-export-data-with-backend'. See for example, how
> `org-latex-headline' formats headings (`text' binding in the function).
>
> If that's the case, you need to know exactly what you want. It is pretty
> obvious for bold markup, but what would happen to, e.g., a_b or \alpha
> or <>?
>

Thanks for the tip. What I'm thinking more is somehow getting the heading
pre-output generation, stripping any characters that `org` would consider
special (I'm hoping there's already a function that can at least mark
'markup' text in a given org string), and _then_ passing it to whatever ox
function is responsible for using the title. That way it's as generic as it
can possibly be.

I confess though that I don't follow exactly what you're talking about
defining a temporary export back-end. Why would that be necessary or
beneficial to the end of teaching org how to use only the 'plain text' of a
heading for the title in N ox backends?

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-04-21 Thread Tim Visher
On Wed, Apr 21, 2021 at 2:39 AM Dr. Arne Babenhauserheide 
wrote:

>
> Jens Lechtenboerger  writes:
>
> > On 2021-04-20, Tim Visher wrote:
> >
> >> I guess regardless it sounds like if I were to go to the trouble of
> making
> >> a patch for this it would be good to make sure that it was behind an
> option
> >> and probably defaulting to the current HEAD behavior of including the
> ASCII
> >> markup with an option to strip the non-word characters from it.
> >
> > That would be great.
>
> It is something that could also benefit the LaTeX export. Having special
> characters in the pdftitle can make the export fail, but those
> characters (like @@latex:\something@@) can make the latex-compilation
> fail.


Awesome. Do you know whether there's an official way to share this sort of
behavior between ox backends or is it just creating a function and calling
it from both places or something?

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-04-20 Thread Tim Visher
Thanks so much for getting back to me, Jens.

On Tue, Apr 20, 2021 at 12:59 AM Jens Lechtenboerger <
jens.lechtenboer...@wi.uni-muenster.de> wrote:

> On 2021-04-19, Kyle Meyer wrote:
>
> > Tim Visher writes:
> >
> >> Unfortunately, the title now is essentially the exact text of the org
> >> heading, which is awkward in terms of readability for a general audience
> >> (and probably for SEO etc.). I know I said in my original message that I
> >> think stripping all the markup characters would be going too far but
> now I
> >> think I've come full circle and rendering the title as nothing but the
> >> plain text without any markup information feels like the right solution
> >> given what the title is supposed to convey.
> >>
> >> So, would we be willing to accept a patch to that effect? :)
> >
> > I don't have an informed opinion about the above, but providing a patch
> > might prompt those that do (including TEC, the author of the above
> > commit, as well as Jens, who provided reviews) to give their input.
>
> The following is not a strong opinion: The author writes “what the
> title is supposed to convey”.  If there is *emphasis*, why not
> export that as ASCII markup to HTML?
>
> With an additional option, authors could choose.
>

I guess I don't have a super strong opinion here either. Ironically, coming
from someone who spends a significant portion of their day reading raw
org/markdown documents with no problem, something about even the ASCII
style markup in the title looks wrong to me. I don't do SEO and
nothing in MDN's
article <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title>
indicates
that non word characters have a negative affect anyway but it just looks
strange to my eyes.

I guess regardless it sounds like if I were to go to the trouble of making
a patch for this it would be good to make sure that it was behind an option
and probably defaulting to the current HEAD behavior of including the ASCII
markup with an option to strip the non-word characters from it.

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-04-11 Thread Tim Visher
On Tue, Mar 30, 2021 at 6:58 PM Tim Visher  wrote:

> On Wed, Jan 20, 2021 at 11:10 PM Kyle Meyer  wrote:
>
>> Tim Visher writes:
>>
>> > Nice! I don't know enough about `org-export` but FWIW the use case I
>> have
>> > is not to have an explicit `title` property but instead just the default
>> > title of the heading contents. I assume that's all handled
>> transparently by
>> > the `(plist-get …` section.
>> >
>> > Do you have any idea the timeline for getting that patch merged?
>>
>> It's been applied to master (f4b9f9808).  Please report back if you
>> still encounter the problem in your use case.
>>
>
> Unfortunately, the title now is essentially the exact text of the org
> heading, which is awkward in terms of readability for a general audience
> (and probably for SEO etc.). I know I said in my original message that I
> think stripping all the markup characters would be going too far but now I
> think I've come full circle and rendering the title as nothing but the
> plain text without any markup information feels like the right solution
> given what the title is supposed to convey.
>
> So, would we be willing to accept a patch to that effect? :)
>

Ping again on this. Any interest in a patch that would transform the
heading into only plaintext without any markup characters for use in the
 element?


Re: ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-03-30 Thread Tim Visher
On Wed, Jan 20, 2021 at 11:10 PM Kyle Meyer  wrote:

> Tim Visher writes:
>
> > Nice! I don't know enough about `org-export` but FWIW the use case I have
> > is not to have an explicit `title` property but instead just the default
> > title of the heading contents. I assume that's all handled transparently
> by
> > the `(plist-get …` section.
> >
> > Do you have any idea the timeline for getting that patch merged?
>
> It's been applied to master (f4b9f9808).  Please report back if you
> still encounter the problem in your use case.
>

I (finally) got around to testing this out. Initially I thought it had been
released in 9.4.5 but AFAICT that's not the case. Does org not get released
from `master`?

Anyway, we're a step further now in that the title appears to be set using
no markup, so that's .

Unfortunately, the title now is essentially the exact text of the org
heading, which is awkward in terms of readability for a general audience
(and probably for SEO etc.). I know I said in my original message that I
think stripping all the markup characters would be going too far but now I
think I've come full circle and rendering the title as nothing but the
plain text without any markup information feels like the right solution
given what the title is supposed to convey.

So, would we be willing to accept a patch to that effect? :)


Re: ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-01-13 Thread Tim Visher
On Tue, Jan 12, 2021 at 10:43 PM Kyle Meyer  wrote:

> Tim Visher writes:
>
> > On Mon, Jan 11, 2021 at 8:19 PM Kyle Meyer  wrote:
>
> >> Thanks for reporting.  Is this addressed by the in-progress series at
> >> <https://orgmode.org/list/87o8hwpz34@gmail.com/>?
> >>
> >
> > IIUC yes. I believe the following section of the diff should address it.
> [...]
> > If I'm reading the code correctly, `org-html-plain-text` is a specialized
> > form of converting org data into a plain text string with no markup. If I
> > have that correct then I believe you're right.
> >
> > Is that your read as well?
>
> Yep.  And as a light test:
>
> #+title: a *b* c
>
> exports
>
>   a *b* c
>
> rather than
>
>   a b c
>

Nice! I don't know enough about `org-export` but FWIW the use case I have
is not to have an explicit `title` property but instead just the default
title of the heading contents. I assume that's all handled transparently by
the `(plist-get …` section.

Do you have any idea the timeline for getting that patch merged?


Re: ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-01-12 Thread Tim Visher
On Mon, Jan 11, 2021 at 8:19 PM Kyle Meyer  wrote:

> Tim Visher writes:
>
> > Hi all,
> >
> > I noticed over the weekend that the `` tag in an ox-html document
> is
> > populated with HTML when inline formatting like bold or italics is used.
> [...]
> > Is this something we'd take a patch for?
>
> Thanks for reporting.  Is this addressed by the in-progress series at
> <https://orgmode.org/list/87o8hwpz34@gmail.com/>?
>

IIUC yes. I believe the following section of the diff should address it.

```
+  (let* ((title (org-html-plain-text
+ (org-element-interpret-data (plist-get info :title)) info))
+ ;; Set title to an invisible character instead of leaving it
+ ;; empty, which is invalid.
+ (title (if (org-string-nw-p title) title ""))
```

If I'm reading the code correctly, `org-html-plain-text` is a specialized
form of converting org data into a plain text string with no markup. If I
have that correct then I believe you're right.

Is that your read as well?


How to use `open` to handle `message:*` links on macOS

2021-01-11 Thread Tim Visher
Hi Everyone,

I'd like to be able to whack `C-c C-o` on `message:*` links on macOS and
have it call `open` on the contents. Is there a way to make that happen?

My intent is to be able to save a deep link to a Mail.app message in an org
document.

Thanks in advance!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


ox-html Incorrectly (?) Puts HTML Into the `` Tag

2021-01-11 Thread Tim Visher
Hi all,

I noticed over the weekend that the `` tag in an ox-html document is
populated with HTML when inline formatting like bold or italics is used.
I'm running org 9.4.4 but even on HEAD

this
behavior seems to be the same where `(org-export-data title …)` is used to
populate the title rather than something that would render the title
textually.

My understanding from MDN
 is that
`title` tags should never contain markup.

Is this something we'd take a patch for? My thought is that the title
should be converted using the text backend by default, perhaps with a
configuration variable that would let you specify a different one (for
instance markdown) but I wouldn't go that far at first. Of course at
minimum since org is textual it could just use the title without exporting
at all but I think that doesn't go far enough. The other possibility would
be to somehow strip all special characters from the title but I think that
goes much too far.

Thanks in advance!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: Possibility to copy text outside EMACS and send it to orgmode document

2021-01-06 Thread Tim Visher
On Wed, Jan 6, 2021 at 1:43 AM Gerardo Moro  wrote:

> Basically that: as I copy (Control-C) text from the browser (Chrome), I
> would like those copied sentences to be sent to a ordered list in an
> OrgMode document:
>
> - copied text 1
> - copied text 2
> - etc.
>
> Any ideas? This would be very useful.
>

On macOS I've done _similar_  things to this (albeit not exactly what
you're asking) by simply generating org text for me to paste in.

For instance I have an applescript `org-current-tab`:

```
…
on org_current_tab()
tell application "Google Chrome"
set the_title to title of active tab of front window
set the_title to my replace_chars(the_title, "[", " ")
set the_title to my replace_chars(the_title, "]", " ")
return "[[" & URL of active tab of front window & "][" & the_title
& "]]" as text
end tell
end org_current_tab
```

Then from anywhere I can activate this applescript and all I need to do is
whack `C-y` in emacs and I get the link pasted in.

It's not hard then to extend this directly into emacs via the `osascript`
executable:

```
(defun org-current-tab
()
  (interactive)
  (unless (eq major-mode 'org-mode)
(user-error "This command must be triggered in an org buffer."))
  (let* ((output (with-temp-buffer
   (call-process
"osascript" nil t nil
"-e" "tell application \"Finder\" to set
current_tab_handlers to (load script file \"current_tab_handlers.scpt\" of
folder \"Dropbox\" of home as alias)"
"-e" "tell current_tab_handlers to org_current_tab()")
   (substring-no-properties (thing-at-point 'line t) 0
-1
(insert output)))
```

I'm not sure what environment you're in so you may not have access to a
system's scripting tool like Applescript but depending on the scripting
facilities of whatever you're targeting maybe you can get most of the way
there. At the worst you could add whatever text you want to your clipboard
and then write some elisp that processes it before writing it to your org
buffer.


Re: xclip/pbcopy/clipboard 'target' for export backends?

2021-01-05 Thread Tim Visher
On Tue, Jan 5, 2021 at 11:13 AM Diego Zamboni  wrote:

> Funny - just a few minutes ago, before reading your message, I learned
> while installing https://github.com/stig/ox-jira.el, about =
> org-export-copy-to-kill-ring=:
>
> org-export-copy-to-kill-ring is a variable defined in ox.el.
>
> Non-nil means pushing export output to the kill ring.
>
> This variable is ignored during asynchronous export.
>
>
> In my brief testing, it does exactly what you want: regardless of the
> export output or method (to a file or to a temporary buffer), the result is
> placed in the clipboard.
>

Hah! Good old C-x M-c M-butterfly. I'll have to play with this myself.


xclip/pbcopy/clipboard 'target' for export backends?

2021-01-05 Thread Tim Visher
Hi Everyone,

I'm interested in adding something to the export dispatcher that would
automatically put the exported text (or perhaps even file?) onto my
clipboard.

Preferably I'd like to define this once and have it available to each
backend. So maybe I want markdown this time but rather than to a buffer or
file I want it to go straight to my clipboard. Next time I want HTML or
Plain Text but the same thing.

Can anyone give me some hints on where to start looking for that? Or maybe
it's already been done?

Thanks in advance!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es


Re: Splitting large org file into smaller ones

2020-05-30 Thread Tim Visher
On Sat, May 30, 2020 at 6:09 AM Marvin M. Doyley 
wrote:

> Is there an efficient way to split a large org file into smaller ones?
>
> Lets say I have a master file with the following
>
> * Notes
> **  Candidate A
> …
> **  Candidate B
> …
>
> How do I export the subtree to separate org files, say
>
> - Candidate-a.org 
> - Candidate-b.org 
>

This seems like it would be fairly trivial with a keyboard macro. Certainly
not the most satisfying solution but if you're not doing this all the time
it might be the closest option.


Re: File Scoped Properties?

2020-03-24 Thread Tim Visher
On Mon, Mar 9, 2020 at 9:24 AM Tim Visher  wrote:

> On Fri, Mar 6, 2020 at 9:09 AM Tim Visher  wrote:
>
>> Thanks for the response, Eric. :)
>>
>> On Fri, Mar 6, 2020 at 1:51 AM Fraga, Eric  wrote:
>>
>>> On Thursday,  5 Mar 2020 at 10:28, Tim Visher wrote:
>>> > I _am_ able to get it to work by adding a file local variable like
>>> >
>>> > ```
>>> > # Local Variables:
>>> > # org-attach-id-dir: "~/.foo/data"
>>> > # End:
>>> > ```
>>> >
>>> > but then whenever I open the file it tells me it's possibly not safe
>>> to set
>>> > that.
>>>
>>> You've already received a more org-ish response but I'll give you an
>>> Emacs response to this part of your post: Emacs is simply making sure
>>> you are aware that a variable is being set when visiting a file.
>>>
>>
>> My question was more around why I had to do it at all since based on my
>> reading of the manual it seems like I should've been able to do this with
>> some kind of file-wide property. Specifically, I've never been able to wrap
>> my head around `(info "(org) Property Syntax")`.
>>
>> "Properties are key–value pairs. When they are associated with a single
>> entry or with a tree…," for instance, seems to imply by "When they are
>> associated with a single entry…" that they can be associated with all the
>> entries (or a particular tree or node).
>>
>> Anyway, I think between you and Gustav I finally have this sorted.
>>
>>1. To set properties at the top level of a file you need to use the
>>`#+PROPERTY:  ` syntax. I've been trying to
>>figure out how I misinterpreted that in the past and I _think_ it was
>>because I assumed that the `#+PROPERTY` was actually `#+` as in
>>`#+DIR` rather than `#+PROPERTY: DIR`. It looks like to set a file local
>>property in an org file you _must_ (at least on 9.3 or earlier) use the
>>`#+PROPERTY:  ` syntax.
>>
>>2. Even then by default org-attach property inheritance is set to
>>`'selective` and `org-use-property-inheritance` is set to off. I've now
>>customized `org-use-property-inheritance` to `'("DIR")` which I believe
>>says that I consider the `DIR` property to be a possible candidate for
>>inheritance and no others. I'm a little concerned about performance
>>implications as the manual gives me all kinds of scary warnings but we'll
>>see about that.
>>
>> Anyway this appears to work as I expect it to. I don't have to set a
>> file-local variable to anything. I'm using org properties. And
>> `org-attach-dir` now returns the proper directory for this file.
>>
>> Thanks all! If you think I'm still misunderstanding something please
>> correct me. :)
>>
>
> I'll go ahead and correct myself. (-‸ლ)
>
> It turns out that I wasn't understanding what the `DIR` property actually
> does. If `DIR` is set, it makes that the attachment directory, period. In
> other words it's different than the default `./data/` prefix directory in
> that ID paths are not then suffixed upon the end of it like
> `./data/XX/X-XXX-XXX/` for each entry. Instead, if you have `DIR` set,
> that headings attachment directory == `DIR`.
>
> So the way to change the attachment directory prefix is just not to mess
> with `DIR` at all. Instead, you must set the variable `org-attach-id-dir`,
> and if you want that to be local to a file the natural way to do that is
> with a file-local variable.
>
> ```
> # Local Variables:
> # org-attach-id-dir: "~/.foo/data"
> # End:
> ```
>
> Cheers. :)
>

This ended up producing more of a learning opportunity than I had initially
suspected and I wrote it up on my blog. In case anyone else is interested
in the details:
https://blog.twonegatives.com/post/613474532727095296/how-to-set-the-attach-directory-prefix-for

Happy Org!


Re: Automatic Capture of Heading Creation Time In Certain Files?

2020-03-16 Thread Tim Visher
On Sun, Mar 15, 2020 at 11:38 PM  wrote:

> >I would like to automatically have the results of a double prefixed call
> to
> >`org-time-stamp-inactive` inserted as the body of new TODO entries.
>
> Have you tried including %U in your template? See "Template expansion"
> in the Org Mode documentation:
>
> ("t" "Full task capture" entry (file+headline "~/org/tasks.org"
>  "INBOX") "* TODO %?\n%iAdded: %U")
>

I have not although maybe this will be the impetus for me finally trying to
figure out the capture system. At least I know it's intended for this use
case. I also imagine some form of advice around heading insertion could
work.


> >https://five.sentenc.es
>
> Heads up, the ssl on https://five.sentenc.es/ is broken.
>

Thank you. I've corrected it to `http` since I don't think there's any
reason to browse it using SSL.


Automatic Capture of Heading Creation Time In Certain Files?

2020-03-13 Thread Tim Visher
Ohai,

I would like to automatically have the results of a double prefixed call to
`org-time-stamp-inactive` inserted as the body of new TODO entries. I
suspect I can do this with Capture templates but every time I read that
manual section it seems to have a lot more than I want. I'm also reasonably
sure I could write a simple function and override bindings such that all of
the default behaviors of TODO insertion happened _plus_ newline-and-indent,
newline-and-indent, double prefix org-time-stamp-inactive, previous-line,
previous-line.

Am I missing something here or barking up the wrong tree in either
direction?

Thanks in advance!

--

In Christ,

Timmy V.

https://blog.twonegatives.com
https://five.sentenc.es


Re: File Scoped Properties?

2020-03-09 Thread Tim Visher
On Fri, Mar 6, 2020 at 9:09 AM Tim Visher  wrote:

> Thanks for the response, Eric. :)
>
> On Fri, Mar 6, 2020 at 1:51 AM Fraga, Eric  wrote:
>
>> On Thursday,  5 Mar 2020 at 10:28, Tim Visher wrote:
>> > I _am_ able to get it to work by adding a file local variable like
>> >
>> > ```
>> > # Local Variables:
>> > # org-attach-id-dir: "~/.foo/data"
>> > # End:
>> > ```
>> >
>> > but then whenever I open the file it tells me it's possibly not safe to
>> set
>> > that.
>>
>> You've already received a more org-ish response but I'll give you an
>> Emacs response to this part of your post: Emacs is simply making sure
>> you are aware that a variable is being set when visiting a file.
>>
>
> My question was more around why I had to do it at all since based on my
> reading of the manual it seems like I should've been able to do this with
> some kind of file-wide property. Specifically, I've never been able to wrap
> my head around `(info "(org) Property Syntax")`.
>
> "Properties are key–value pairs. When they are associated with a single
> entry or with a tree…," for instance, seems to imply by "When they are
> associated with a single entry…" that they can be associated with all the
> entries (or a particular tree or node).
>
> Anyway, I think between you and Gustav I finally have this sorted.
>
>1. To set properties at the top level of a file you need to use the
>`#+PROPERTY:  ` syntax. I've been trying to
>figure out how I misinterpreted that in the past and I _think_ it was
>because I assumed that the `#+PROPERTY` was actually `#+` as in
>`#+DIR` rather than `#+PROPERTY: DIR`. It looks like to set a file local
>property in an org file you _must_ (at least on 9.3 or earlier) use the
>`#+PROPERTY:  ` syntax.
>
>2. Even then by default org-attach property inheritance is set to
>`'selective` and `org-use-property-inheritance` is set to off. I've now
>customized `org-use-property-inheritance` to `'("DIR")` which I believe
>says that I consider the `DIR` property to be a possible candidate for
>inheritance and no others. I'm a little concerned about performance
>implications as the manual gives me all kinds of scary warnings but we'll
>see about that.
>
> Anyway this appears to work as I expect it to. I don't have to set a
> file-local variable to anything. I'm using org properties. And
> `org-attach-dir` now returns the proper directory for this file.
>
> Thanks all! If you think I'm still misunderstanding something please
> correct me. :)
>

I'll go ahead and correct myself. (-‸ლ)

It turns out that I wasn't understanding what the `DIR` property actually
does. If `DIR` is set, it makes that the attachment directory, period. In
other words it's different than the default `./data/` prefix directory in
that ID paths are not then suffixed upon the end of it like
`./data/XX/X-XXX-XXX/` for each entry. Instead, if you have `DIR` set,
that headings attachment directory == `DIR`.

So the way to change the attachment directory prefix is just not to mess
with `DIR` at all. Instead, you must set the variable `org-attach-id-dir`,
and if you want that to be local to a file the natural way to do that is
with a file-local variable.

```
# Local Variables:
# org-attach-id-dir: "~/.foo/data"
# End:
```

Cheers. :)


Re: File Scoped Properties?

2020-03-06 Thread Tim Visher
Thanks for the response, Eric. :)

On Fri, Mar 6, 2020 at 1:51 AM Fraga, Eric  wrote:

> On Thursday,  5 Mar 2020 at 10:28, Tim Visher wrote:
> > I _am_ able to get it to work by adding a file local variable like
> >
> > ```
> > # Local Variables:
> > # org-attach-id-dir: "~/.foo/data"
> > # End:
> > ```
> >
> > but then whenever I open the file it tells me it's possibly not safe to
> set
> > that.
>
> You've already received a more org-ish response but I'll give you an
> Emacs response to this part of your post: Emacs is simply making sure
> you are aware that a variable is being set when visiting a file.
>

Yep. That's fully understood. I'm less clear on why certain variables are
considered safe and some are not but that doesn't seem relevant. I've done
enough with file local and directory local variables in the past that I
have a pretty clear understanding of what they do.

My question was more around why I had to do it at all since based on my
reading of the manual it seems like I should've been able to do this with
some kind of file-wide property. Specifically, I've never been able to wrap
my head around `(info "(org) Property Syntax")`.

"Properties are key–value pairs. When they are associated with a single
entry or with a tree…," for instance, seems to imply by "When they are
associated with a single entry…" that they can be associated with all the
entries (or a particular tree or node).

Anyway, I think between you and Gustav I finally have this sorted.

   1. To set properties at the top level of a file you need to use the
   `#+PROPERTY:  ` syntax. I've been trying to
   figure out how I misinterpreted that in the past and I _think_ it was
   because I assumed that the `#+PROPERTY` was actually `#+` as in
   `#+DIR` rather than `#+PROPERTY: DIR`. It looks like to set a file local
   property in an org file you _must_ (at least on 9.3 or earlier) use the
   `#+PROPERTY:  ` syntax.

   2. Even then by default org-attach property inheritance is set to
   `'selective` and `org-use-property-inheritance` is set to off. I've now
   customized `org-use-property-inheritance` to `'("DIR")` which I believe
   says that I consider the `DIR` property to be a possible candidate for
   inheritance and no others. I'm a little concerned about performance
   implications as the manual gives me all kinds of scary warnings but we'll
   see about that.

Anyway this appears to work as I expect it to. I don't have to set a
file-local variable to anything. I'm using org properties. And
`org-attach-dir` now returns the proper directory for this file.

Thanks all! If you think I'm still misunderstanding something please
correct me. :)

--

In Christ,

Timmy V.

https://blog.twonegatives.com
https://five.sentenc.es


Re: Nested quote blocks?

2020-03-05 Thread Tim Visher
On Thu, Mar 5, 2020 at 1:45 AM Fraga, Eric  wrote:

> > IIUC, your solution should work but it's necessarily tied to specific
> > export backends, right?
>
> It is partly but the general concept of using special blocks works for
> HTML also.  You end up with code that looks like this:
>
> ,
> | 
> | 
> | and this is the inner block
> | 
> |
> | 
> `
>
> which means you can customize its appearance using appropriate CSS code.


Sounds great. I'll try to hack on this when I have some free time. :)


File Scoped Properties?

2020-03-05 Thread Tim Visher
Hello,

I'm trying to get org-attach to use a different data directory for a
particular file.

My understanding is that this is controlled by `org-attach-id-dir` by
default but can be overridden at the file or entry level by use of the
`DIR` property. I can successfully override it at the entry level by adding
`DIR` to the entries properties but I can't figure out how to set it for
all entries in the file.

I tried:

```
#+DIR: ~/.foo/data
```

as the first line of the file.

I _am_ able to get it to work by adding a file local variable like

```
# Local Variables:
# org-attach-id-dir: "~/.foo/data"
# End:
```

but then whenever I open the file it tells me it's possibly not safe to set
that.

Any ideas?

--

In Christ,

Timmy V.

https://blog.twonegatives.com
https://five.sentenc.es


Re: [PATCH]: org-attach.el: Use `force' arg everywhere in `org-attach-delete-all'

2020-03-04 Thread Tim Visher
Hi Kyle,

Thanks for feedback!

--

>From 626bd68a324cd65ba697dc1ccafdeff5808fd4c0 Mon Sep 17 00:00:00 2001
From: Tim Visher 
Date: Tue, 3 Mar 2020 09:14:44 -0500
Subject: [PATCH] org-attach.el: Use `force' arg everywhere in
 `org-attach-delete-all'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-attach.el (org-attach-delete-all): Use `force' arg
throughout function.

`org-attach-delete-all` advertised a `force` option but passing it
only forced its way past the initial "Really remove all…" query.  This
was unexpected and not properly documented.

This extends the use of the `force` argument to the `delete-directory`
call and documents its meaning in the docstring.

TINYCHANGE
---
 lisp/org-attach.el | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 429d69021..57d1360fc 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -574,13 +574,18 @@ The attachment is created as an Emacs buffer."
 (defun org-attach-delete-all ( force)
   "Delete all attachments from the current outline node.
 This actually deletes the entire attachment directory.
-A safer way is to open the directory in dired and delete from there."
+A safer way is to open the directory in dired and delete from there.
+
+With prefix argument FORCE, directory will be recursively deleted
+with no prompts."
   (interactive "P")
   (let ((attach-dir (org-attach-dir)))
 (when (and attach-dir
   (or force
   (yes-or-no-p "Really remove all attachments of this
entry? ")))
-  (delete-directory attach-dir (yes-or-no-p "Recursive?") t)
+  (delete-directory attach-dir
+   (or force (yes-or-no-p "Recursive?"))
+   t)
   (message "Attachment directory removed")
   (run-hook-with-args 'org-attach-after-change-hook attach-dir)
   (org-attach-untag
--
2.19.1


0001-org-attach.el-Use-force-arg-everywhere-in-org-attach.patch
Description: Binary data


Re: Nested quote blocks?

2020-03-04 Thread Tim Visher
Thanks for responding, Eric. :)

On Wed, Mar 4, 2020 at 2:28 AM Fraga, Eric  wrote:

> On Tuesday,  3 Mar 2020 at 12:57, Tim Visher wrote:
> > Is there a way to get nested quotes blocks to work?
>
> What is your actual goal?  That is, what you do mean by "to work"?  I
> ask because although, as Nicolas has said, you cannot do this directly
> with org, you can achieve some specific goals with special blocks and/or
> drawers.  For instance, if your goal were to export to LaTeX, this code
> would do the job:
>
> #+begin_src org
>   ,#+latex_header: \let\myquote\quote
>   ,* testing nested blocks
>   Joe said:
>
>   ,#+begin_quote
>   This is the outer block.
>
>   ,#+begin_myquote
>   and this is the inner block
>   ,#+end_myquote
>
>   followed by the outer block.
>   ,#+end_quote
>
>   and that is all folks.
> #+end_src
>

I can demonstrate my goal with Markdown like so
<https://gist.github.com/timvisher/9500d76d609c593b6bcfbb1c6c529ae5>. If
you view the raw file
<https://gist.githubusercontent.com/timvisher/9500d76d609c593b6bcfbb1c6c529ae5/raw/1c5d16ee9c4ad6e33d99f450e5f6e8ce323bdd83/x.md>
you
can see how the quote level nests and yet all of Markdown's markup is
rendered as well. Thus each block quoting 'level' is a fully functional
Markdown context.

IIUC, your solution should work but it's necessarily tied to specific
export backends, right? I would be happy if it could be made to work for
the HTML because that's often my intermediary form these days for getting
text out of Org into something others find less intimidating. :)


Nested quote blocks?

2020-03-03 Thread Tim Visher
Hello,

Is there a way to get nested quotes blocks to work?

AFAICT:

```
#+begin_quote

foo

#+begin_quote
bar
#+end_quote

bat
#end_quote
```

Doesn't work.

Ideally I'm kind of looking for a full functional sub org context inside
there. Maybe I should be using some kind of source block?

--

In Christ,

Timmy V.

https://blog.twonegatives.com
https://five.sentenc.es


[PATCH]: org-attach.el: Use `force' arg everywhere in `org-attach-delete-all'

2020-03-03 Thread Tim Visher
>From 9a8abeee9109f24d8643990a561c16c8b402b1b1 Mon Sep 17 00:00:00 2001
From: Tim Visher 
Date: Tue, 3 Mar 2020 09:14:44 -0500
Subject: [PATCH] org-attach.el: Use `force' arg everywhere in
 `org-attach-delete-all'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-attach.el (org-attach-delete-all): Use `force' arg
throughout function.

`org-attach-delete-all` advertised a `force` option but passing it
only forced its way past the initial "Really remove all…" query.  This
was unexpected and not properly documented.

This extends the use of the `force` argument to the `delete-directory`
call and documents its meaning in the docstring.

TINYCHANGE
---
 lisp/org-attach.el | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 429d69021..26099aab3 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -574,13 +574,17 @@ The attachment is created as an Emacs buffer."
 (defun org-attach-delete-all ( force)
   "Delete all attachments from the current outline node.
 This actually deletes the entire attachment directory.
-A safer way is to open the directory in dired and delete from there."
+A safer way is to open the directory in dired and delete from there.
+
+If FORCE is truthy, directory will be recursively deleted with no
+prompts."
   (interactive "P")
   (let ((attach-dir (org-attach-dir)))
 (when (and attach-dir
(or force
(yes-or-no-p "Really remove all attachments of this entry? ")))
-  (delete-directory attach-dir (yes-or-no-p "Recursive?") t)
+  (delete-directory attach-dir (or force
+   (yes-or-no-p "Recursive?")) t)
   (message "Attachment directory removed")
   (run-hook-with-args 'org-attach-after-change-hook attach-dir)
   (org-attach-untag
-- 
2.19.1


0001-org-attach.el-Use-force-arg-everywhere-in-org-attach.patch
Description: Binary data


Re: org-mode functional programming library

2020-01-21 Thread Tim Visher
On Mon, Jan 20, 2020 at 6:48 PM Dwarshuis, Nathan J  wrote:

> I recently authored an package called "om.el" which is a functional
> org-mode API akin to dash.el primarily using org-element. Briefly, it
> provides a library of (mostly) pure functions that manipulate the parse
> tree generated by org-element.el, and uses this to either edit or query the
> buffer with all the advantages of functional programming (eg lack of side
> effects, referential transparency, easier testing, etc). The github repo
> for om.el is here: https://github.com/ndwarshuis/om.el.
>
> I'm posting to the mailing list a) for general feedback on this package
> and b) because I am wondering if this would be a good package to include
> with org-mode itself rather than in another repository such as MELPA. The
> code for om.el is tightly integrated with org-element.el and it might make
> sense for development between these to be closely intertwined.
>
> There is also an open submission for this to MELPA and the discussion is
> here: https://github.com/melpa/melpa/pull/6623.
>

Oooo this looks cool. I have a simmering project to have an Evernote like
system built on top of org mode and a set of directories where I've done a
lot of work like this. I'll have to see if I can work this into that and if
I can I'll be sure to open up issues/try to contribute patches etc.


Re:

2019-12-12 Thread Tim Visher
On Thu, Dec 12, 2019 at 1:15 PM Marco Wahl  wrote:

> Tim Visher  writes:
>
> > On Thu, Dec 12, 2019 at 4:14 AM Marco Wahl 
> wrote:
> >
> >> Justin Vallon  writes:
> >>
> >> > When I use "emacs --no-init-file", I get the default distribution org
> >> > packages, and " However,
> >> > in my downloaded-melpa-install of org, it does not work.
> >> >
> >> > Distro org-version is 9.1.9, melpa is 9.3.  describe-key TAB shows
> >> > org-cycle, which is a kitchen-sink function.  The docs of the function
> >> > has not changed between the versions.
> >> >
> >> > I believe " >> > but I don't have any version besides 9.3 in ~/.emacs.d/elpa.
> >>
> >> Possibly you want to switch to the new feature (accessible C-c C-,)
> >> which BTW allows to wrap regions.
> >>
> >> The " >> See the documentation in section Structure Templates.
> >>
> >
> > What feature are you referring to, Marco? My `C-c C-,` sets the heading
> > priority.
>
> This is a reference to the feature announced in ORG-NEWS
> e.g. https://code.orgmode.org/bzg/org-mode/src/master/etc/ORG-NEWS.
>
> Org 9.2 comes with a new template expansion mechanism, combining
> ~org-insert-structure-template~ bound to ~C-c C-,~.
>
> And also the feature is described in the info documentation in section
> "Structure Templates".
>
> Possibly you have defined your personal "C-c C-," Tim?
>

Ah. Apparently I can't press `C-,` in the terminal. So emacs was receiving
`C-c ,`. That makes sense.


Re:

2019-12-12 Thread Tim Visher
On Thu, Dec 12, 2019 at 4:14 AM Marco Wahl  wrote:

> Justin Vallon  writes:
>
> > When I use "emacs --no-init-file", I get the default distribution org
> > packages, and " > in my downloaded-melpa-install of org, it does not work.
> >
> > Distro org-version is 9.1.9, melpa is 9.3.  describe-key TAB shows
> > org-cycle, which is a kitchen-sink function.  The docs of the function
> > has not changed between the versions.
> >
> > I believe " > but I don't have any version besides 9.3 in ~/.emacs.d/elpa.
>
> Possibly you want to switch to the new feature (accessible C-c C-,)
> which BTW allows to wrap regions.
>
> The " See the documentation in section Structure Templates.
>

What feature are you referring to, Marco? My `C-c C-,` sets the heading
priority.


Re: Set heading text from elisp?

2019-11-13 Thread Tim Visher
Nice! That looks like exactly what I wanted. Not sure how I missed that in
my apropos search. I think I may have only searched for `headline` or
something.

On Wed, Nov 13, 2019 at 7:08 AM Mikhail Skorzhinskii 
wrote:

> I am not sure if this is exactly what you're asking, but for programatic
> heading edits I am using this snippet:
>
> (let ((headline-only-text (org-get-heading t t t t)))
>   (org-edit-headline (concat "Web-page: " headline-only-text)))
>
> Probably the better way is to use org element API, but for small, rarely
> executed personal helpers I think this is OK.
>
> *I'm Wondering If There's Builtin Support For Editing Components Of The
> Heading? I'm Trying To Set The Text Component (I.E. `(Nth 4
> (Org-Heading-Components))`) Without Altering Anything Else And While I Can
> Obviously Achieve This With Generic Elisp I Wanted To Be Sure I Had To.*I'm
> wondering if there's builtin support for editing components of the heading?
> I'm trying to set the text component (i.e. `(nth 4
> (org-heading-components))`) without altering anything else and while I can
> obviously achieve this with generic elisp I wanted to be sure I had to.
>
> The cleanest elisp I came up with was:
>
> ```
> (save-excursion
>   (org-back-to-heading t)
>   (let (case-fold-search)
> (looking-at org-complex-heading-regexp)
> (replace-match text t t nil 4)
> (org-align-tags)))
>
> ```
>
> --
>
> In Christ,
>
> Timmy V.
>
> https://blog.twonegatives.com
> https://five.sentenc.es
>
>


Set heading text from elisp?

2019-11-11 Thread Tim Visher
I'm wondering if there's builtin support for editing components of the
heading? I'm trying to set the text component (i.e. `(nth 4
(org-heading-components))`) without altering anything else and while I can
obviously achieve this with generic elisp I wanted to be sure I had to.

The cleanest elisp I came up with was:

```
(save-excursion
  (org-back-to-heading t)
  (let (case-fold-search)
(looking-at org-complex-heading-regexp)
(replace-match text t t nil 4)
(org-align-tags)))

```

--

In Christ,

Timmy V.

https://blog.twonegatives.com
https://five.sentenc.es


Re: [O] Ag (the Silver Searcher) knows about Org files now

2017-08-31 Thread Tim Visher
It's worth noting that you can already achieve that behavior using [-G |
--file-search-regex .*.org

```
ag -G '.*\.org'
```

The emacs ag package is also quite good. https://github.com/Wilfred/ag.el

On Thu, Aug 31, 2017 at 12:36 PM, William Denton  wrote:

> A recent commit means that the very useful tool ag recognizes --org as an
> option to let you search just Org files.
>
> Ag: https://github.com/ggreer/the_silver_searcher
>
> It'll take a while for that to make its way into package updates on
> different operating systems, but it's good news.
>
> Bill
> --
> William Denton :: Toronto, Canada   ---   Listening to Art:
> https://listeningtoart.org/
> https://www.miskatonic.org/ ---   GHG.EARTH: http://ghg.earth/
> Caveat lector.  ---   STAPLR: http://staplr.org/
>
>


Re: [O] Automatic mtime and ctime on all or select group of trees?

2017-08-31 Thread Tim Visher
On Thu, Aug 31, 2017 at 9:44 AM, Eric S Fraga <esfli...@gmail.com> wrote:

> On Thursday, 31 Aug 2017 at 07:55, Tim Visher wrote:
> > I would like to track the time I created a tree and the last time it was
> > edited, like ctime and mtime on a filesystem. Is that possible to have
> > happen automatically?
>
> I don't know of any org mechanism for handling this, especially the
> modified time element.  However, I would suggest you consider using a
> revision control system (mercurial, git) which would allow even finer
> tracking than this...
>

Thanks for the suggestion. It doesn't really meet my needs here in that I'm
really looking for org to behave more like a filesystem, not something that
I have to manually commit changes to.

If this doesn't already exist, does org already provide hooks or something
that I can plug in to? I would assume a heading-created and
heading-modified hook of some kind would allow me to implement my own
solution fairly cleanly.


[O] EXPORT_FILE_NAME property default to heading content?

2017-08-31 Thread Tim Visher
I like the filename of the exported file to always match the content of the
heading being exported. Is that possible? At the moment I basically
duplicate it like:

** Foo Heading
   :PROPERTIES:
   :EXPORT_FILE_NAME: Foo Heading
   :END:

Thanks in advance!

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail


[O] Automatic mtime and ctime on all or select group of trees?

2017-08-31 Thread Tim Visher
I would like to track the time I created a tree and the last time it was
edited, like ctime and mtime on a filesystem. Is that possible to have
happen automatically?

Thanks in advance!

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail


[O] Is it possible to use footnote style links in PDF export?

2017-08-31 Thread Tim Visher
I have been exporting PDFs of my trees lately to print. I would like the
exported PDFs to not include hot links but instead to use footnote style
links. Is that possible?

Ideally, I would like to be able to export these footnote style links
directly to the print spool as a latex formatted document. That'd be even
better.

Thanks in advance!

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail


Re: [O] [org] different key binding between GUI emacs and emacs -nw

2017-05-30 Thread Tim Visher
On Tue, May 30, 2017 at 8:29 AM, Jean-Christophe Helary <
jean.christophe.hel...@gmail.com> wrote:

>
> On May 30, 2017, at 21:21, Tim Visher <tim.vis...@gmail.com> wrote:
>
> Sometimes your Terminal application captures these 'extended' bindings.
>
>
> It is the opposite that's happening. Terminal works fine. It is the GUI
> that does not accept the bindings. And as I wrote, it is not limited to my
> macOS (Emacs.app and Aquamacs show the same behavior) but to other people's
> GTK+ linux or Xubuntu. So it seems that's something that aught to be
> investigated and eventually fixed.
>

Ah I'm sorry. I misread the OP. That is strange.


Re: [O] different key binding between GUI emacs and emacs -nw

2017-05-30 Thread Tim Visher
Sometimes your Terminal application captures these 'extended' bindings. If
you know that your Terminal application isn't doing that (for instance, by
using key sequence help like ` k M-`) then I don't have any other
help to offer. I've always just accepted that org mode keybindings differ
between terminal and gui.

On Tue, May 30, 2017 at 3:37 AM, Jean-Christophe Helary <
jean.christophe.hel...@gmail.com> wrote:

>
> > On May 30, 2017, at 15:51, Nicolas Goaziou 
> wrote:
> >
> >> http://lists.gnu.org/archive/html/help-gnu-emacs/2017-05/msg00306.html
> >>
> >> Let me know if you need extra information.
> >
> > What happens if you replace, e.g.,
> >
> >  (org-defkey org-mode-map [(meta left)]  'org-metaleft)
> >
> > with
> >
> >  (org-defkey org-mode-map (kbd "M-")  'org-metaleft)
> >
> > in "org.el"?
>
> Nothing changes.
>
> Jean-Christophe
>
>


Re: [O] Add TODO from external app?

2014-04-16 Thread Tim Visher
On Wed, Apr 16, 2014 at 12:31 PM, Bastien b...@gnu.org wrote:
 Hi Lawrence,

 Lawrence Bottorff borg...@gmail.com writes:

 I've seen various things for interacting with org mode from external
 apps. I found org-protocol, as well as a Mutt-to-org mode article.
 Per the tittle, I want to be able to add new TODO items from, say, an
 email or a PHP-based web page form. Is this just brute force external
 file manipulation, i.e., e.g., my PHP code would simply open a .org
 file and concatenate a properly formatted TODO line . . . or are
 there more sophisticated ways of talking to emacs/org-mode from
 without?

 I'm aware of such sophisticated ways, so for now simply open a .org
 file and write to it.

Emacs can be used as a scripting environment so if you can figure out
how to do it from elisp that might be a more sophisticated way.

That said, one of the beauties of org is that it's just plain text and
the format for a link is pretty darn simple. So I've always just
written to the file using the format.

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail