volevo anche un modo per org-refile
per refile facilmente ad una sottostruttura, così ho scritto un po 'di codice e generalizzato in modo che esso fisserà un obiettivo immediato arbitrario ovunque (non solo nello stesso file).
Utilizzo base è quello di spostare da qualche parte in Tree B
e digitare Cc Cx Cm per contrassegnare l'obiettivo per riclassificazione, per poi passare alla voce in Tree A
che si desidera refile e digitare Cc Cw che immediatamente refile nella posizione target impostata su Tree B
senza che venga richiesto, a meno che non si chiamicon un prefisso arg Cu Cc Cx Cm.
Si noti che se si preme Cc Cw in rapida successione per refile più voci che manterrà l'ordine delle voci, anche se org-reverse-note-order
è impostato su t
, ma è possibile disattivarla per rispettare l'impostazione di org-reverse-note-order
con un prefisso doppio arg Cu Cu Cc Cx Cm.
(defvar org-refile-immediate nil
"Refile immediately using `org-refile-immediate-target' instead of prompting.")
(make-local-variable 'org-refile-immediate)
(defvar org-refile-immediate-preserve-order t
"If last command was also `org-refile' then preserve ordering.")
(make-local-variable 'org-refile-immediate-preserve-order)
(defvar org-refile-immediate-target nil)
"Value uses the same format as an item in `org-refile-targets'."
(make-local-variable 'org-refile-immediate-target)
(defadvice org-refile (around org-immediate activate)
(if (not org-refile-immediate)
ad-do-it
;; if last command was `org-refile' then preserve ordering
(let ((org-reverse-note-order
(if (and org-refile-immediate-preserve-order
(eq last-command 'org-refile)) nil org-reverse-note-order)))
(ad-set-arg 2 (assoc org-refile-immediate-target (org-refile-get-targets)))
(prog1 ad-do-it
(setq this-command 'org-refile)))))
(defadvice org-refile-cache-clear (after org-refile-history-clear activate)
(setq org-refile-targets (default-value 'org-refile-targets))
(setq org-refile-immediate nil)
(setq org-refile-immediate-target nil)
(setq org-refile-history nil))
;;;###autoload
(defun org-refile-immediate-target (&optional arg)
"Set current entry as `org-refile' target.
Non-nil turns off `org-refile-immediate', otherwise `org-refile'
will immediately refile without prompting for target using most
recent entry in `org-refile-targets' that matches
`org-refile-immediate-target' as the default."
(interactive "P")
(if (equal arg '(16))
(progn
(setq org-refile-immediate-preserve-order
(not org-refile-immediate-preserve-order))
(message "Order preserving is turned: %s"
(if org-refile-immediate-preserve-order
"on" "off")))
(setq org-refile-immediate (unless arg t))
(make-local-variable 'org-refile-targets)
(let* ((components (org-heading-components))
(level (first components))
(heading (nth 4 components))
(string (substring-no-properties heading)))
(add-to-list 'org-refile-targets
(append (list (buffer-file-name))
(cons :regexp
(format "^%s %s$"
(make-string level ?*)
string))))
(setq org-refile-immediate-target heading))))
(define-key org-mode-map "\C-c\C-x\C-m" 'org-refile-immediate-target)
E 'stato difficile trovare una chiave che era libero sul prefisso Cc Cx, quindi ho usato m con il mnemonico i * mm * ediata
Affinché REFILE di sottostruttura a lavorare (C-c C-w) i tuoi trattini devono rientrare per 2. esempio *** SottotitoliA1. Ho avuto il mio setup di indent come il tuo e non ho potuto farlo funzionare fino a quando non ho capito questo. La domanda – 79E09796
[This] (http://stackoverflow.com/questions/22200312/refile-from-to-file-to-other) potrebbe essere d'aiuto. Puoi (temporaneamente) aggiungere il file corrente a "org-refile-targets" con un ': maxlevel' of> = 2 set ogni volta che ricomponi. Tuttavia, il mio lisp-fu non è abbastanza forte per aiutarti in questo. – Alex