dsdshcym / dsdshcym.github.io

https://yiming.dev/
1 stars 1 forks source link

My org-refile workflow - Yiming Chen #16

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

My org-refile workflow - Yiming Chen

https://yiming.dev/blog/2018/03/02/my-org-refile-workflow/

AtomicNess123 commented 4 years ago

Have you tried using (setq org-refile-allow-creating-parent-nodes 'confirm)? I'd like to be able to create my subheadings on the spot, but I haven't been able to make this happen. Have been searching online for hours. Let me know if you use this features. Thanks!

dsdshcym commented 4 years ago

@Gahamelas Yes, I'm using this feature and sometimes I'd create a new heading as a refile target: screen

What input did you use when trying to create a new heading?

AtomicNess123 commented 4 years ago

I can't see very well what's going on because it's a bit fast on the GIF. Do you use HELM? With Helmmoving up and down among completions doesn't place the value in the minibuffer, so typing "/NEWHEADING" passes the complete path "/NEWHEADING" which isn't a valid location. Do you need to write the whole path of the new heading (file.org/heading/newheading)?

JohnLunzer commented 4 years ago

Very very nice. The org-search command is by itself a gem, so simple and so effective. I'm always surprised by the number of common sense commands that don't exist in vanilla emacs or vanilla org.

wangwb98 commented 3 years ago

@Gahamelas I had same question as you and found the solution is in helm manual. Just use C-c C-y and the current selected item will be yanked into the input buffer. That's easiest way I have found so far.

wangwb98 commented 3 years ago

Just found C-l (low level L) also works for this purpose.

AtomicNess123 commented 3 years ago

@wangwb98 Regarding your answers:

C-c C-y runs the command org-evaluate-time-range (found in org-mode-map), which is an interactive Lisp closure
in ‘org-9.3.6/org.el’.
C-l runs the command recenter-top-bottom (found in global-map), which is an interactive compiled Lisp function
in ‘window.el’.

So I don't know which underlying commands you have mapped to these key bindings.

wangwb98 commented 3 years ago

@wangwb98 Regarding your answers:

C-c C-y runs the command org-evaluate-time-range (found in org-mode-map), which is an interactive Lisp closure
in ‘org-9.3.6/org.el’.
C-l runs the command recenter-top-bottom (found in global-map), which is an interactive compiled Lisp function
in ‘window.el’.

So I don't know which underlying commands you have mapped to these key bindings.

First, invoke the org-refile command when your cursor is in the org file . Spacemacs by default bind it to SPC m s r. Then the "Helm Org Refile" shows up, you can move up&down to find the item you want to refile to, and directly press C-c C-y. Remember this is a key combinding in helm, not in org mode.

benthamite commented 3 years ago

I really like this workflow. I would like to tweak it slightly so as to have a separate search function (in addition to +org/opened-buffer-files) that lets me search for headings within the active buffer only (rather than all open org buffers). Presumably these two search functions should set org-refile-targets differently, one to ((+org/opened-buffer-files :maxlevel . 9)) and the other to whatever value restricts queries to headings in the active buffer, but I don't know how to define these functions (I'm new to Emacs). Any help would be appreciated.

benthamite commented 3 years ago

Further to my previous comment, I found a package that allows me to run search queries both in the current buffer and in all open buffers or agenda files, and that it does so without any delays in fetching headings and without requiring periodic cache regeneration: helm-org-ql. You may want to check it out—the speed is amazing.

AtomicNess123 commented 3 years ago

Further to my previous comment, I found a package that allows me to run search queries both in the current buffer and in all open buffers or agenda files, and that it does so without any delays in fetching headings and without requiring periodic cache regeneration: helm-org-ql. You may want to check it out—the speed is amazing.

I tried using helm-org-ql but get no results. Do you call it interactively?

benthamite commented 3 years ago

This is due to a bug with dash.el, which was fixed yesterday. Please update the dash.el package and try again. I can confirm that it works fine since the fix (whereas before I was also getting no results).

AtomicNess123 commented 3 years ago

Still same thing. I call the function, type a keyword, and nothing happens.

benthamite commented 3 years ago

Mmh, not sure then. Perhaps the fix didn't fully resolve the issue, though it may be unrelated.

dsdshcym commented 3 years ago

Hi @benthamite, glad to know that you've found helm-org-ql!

I don't use helm but I do use org-ql for its agenda-like view. It's so fast and I can't wait for it to support ivy.

I also use counsel-imenu (you may try helm-imenu or imenu) for navigating within current org buffer. Hope it's helpful for you.

AtomicNess123 commented 3 years ago

Thanks! What would be the difference between counsel-imenu and helm-swoop?

benthamite commented 3 years ago

I don't use helm but I do use org-ql for its agenda-like view.

Thanks, this aspect of org-ql looks very promising indeed.

andrej1919 commented 2 years ago

Silly newbie question: is it possible to add (besides opened-buffer-files) all files in particular folder to org-refile-targets? For instance something like "~/orgfiles/*.org"

sebasmonia commented 2 years ago

@andrej1919 coincidence, I just did that, based on the code on this post and another one that added the org-agenda-files to the refile targets (IIRC a Stack Exchange answer).

  (setf org-agenda-files '("/path/to-all/myorgfiles"))
  (setf org-refile-targets
   '((nil :maxlevel . 3)
     (org-agenda-files :maxlevel . 3)))

EDIT: see https://stackoverflow.com/questions/22200312/refile-from-one-file-to-other

dsdshcym commented 2 years ago

@andrej1919 Here is my current org-refile-targets config:

  (defun +org/opened-buffer-files ()
    "Return the list of files currently opened in emacs"
    (delq nil
          (mapcar (lambda (x)
                    (if (and (buffer-file-name x)
                             (string-match "\\.org$"
                                           (buffer-file-name x)))
                        (buffer-file-name x)))
                  (buffer-list))))
  (setq org-refile-targets `((+org/opened-buffer-files :maxlevel . 9)
                              (,(file-expand-wildcards  "~/Org/Archived/*.org_archive") :maxlevel . 1)))

So for your demand, I think this would work

(setq org-refile-targets `((,(file-expand-wildcards  "~/orgfiles/*.org") :maxlevel . 1))
andrej1919 commented 2 years ago

Great! Thank you very much!