0

The combination of org capture, org-metaleft (bound to S-LEFT), and refiling can mess up an org file. Here is an example:

  • Start a new heading with quick capture, say *** new. This heading is refiled depending on your quick capture template, say ** Miscellaneous.
  • Press S-LEFT twice, which is bound to org-metaleft and which I often use to go back a word instead of M-b. The heading *** new becomes * new and all the next level 2 headings will become children of this new heading.
  • Refile with C-c C-w, say to * Today. The heading becomes ** new and carries all the children with it to the new location.

The problem with this behavior is that it is completely hidden, unlike in the main buffer where I would see it happening. So I think org-metaleft should be disabled in org capture.

Why is it enabled, and how to turn it off?

  • 2
    I don't use a current version of org-mode and do not anticipate installing it any time soon. That being said, a quick Google search lead me to the variable org-capture-mode-map which contains a doc-string: "Keymap for org-capture-mode, a minor mode. Use this map to set additional keybindings for when Org-mode is used for a capture buffer." So, perhaps you can just define the key has having a nil value for the function ... See: emacs.stackexchange.com/questions/7546/… You may need to (require 'org-capture) or use eval-after-load ... – lawlist Nov 12 '19 at 18:10
  • @lawlist I'm curious if you use another software to organize your to-do list and track time? – miguelmorin Dec 7 '19 at 20:41
  • 1
    I use a flat text file for each client to track time using a certain format that is always the same so that I can use a regexp to calculate all of the time spent over a given period; e.g., 0.2 hours -- 12/17/2019: Conference with client. I manually log my time in/out. For the past 5+ years, I have strictly used a custom/modified version of org-mode to keep track of tasks and events, using the same keywords as toodledo.com, which I sync with using a custom/modified of org-toodledo.el. I use a custom/modified version of calfw; and, github.com/lawlist/lorg-calendar – lawlist Dec 7 '19 at 23:28
0

Following @lawlist's comments, C-h k <M-LEFT> on an org-capture buffer shows that the key is bound through org-mode-map. I overrode the keybinding of M-LEFT to a function that checks if the current buffer is an Org-capture buffer:

(defun my-org-is-buffer-org-capture()
  "Checks if the current buffer is an org-capture buffer."
  (string-match-p (regexp-quote "CAPTURE-") (buffer-name)))

(defun my-org-metaleft (&optional arg)
  "Wrapper function for org-metaleft, except in org-capture buffers where it calls backward-word."
  (interactive)
  (if (my-org-is-buffer-org-capture)
      (backward-word)
    (org-metaleft arg)))

(defun my-org-metaright (&optional arg)
  "Wrapper function for org-metaright, except in org-capture buffers where it calls forward-word."
  (interactive)
  (if (is-buffer-org-capture)
      (forward-word)
    (org-metaright arg)))

;; Disable org-metaleft and org-metaright in org-capture buffers
(define-key org-mode-map (kbd "<M-left>") 'my-org-metaleft)
(define-key org-mode-map (kbd "<M-right>") 'my-org-metaright)
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.