1

I have this function

;; Move the point to the first non-whitespace character of the line. ;; If the point is already there, then move it to the beginning of the line. (defun my/smarter-beginning-of-line () (interactive) (if (= (point) (progn (back-to-indentation) (point))) (beginning-of-line))) (keymap-global-set "C-a" 'my/smarter-beginning-of-line) 

The function above works great when writing code:

1 var abc = 5; _ 2 ^ 3 | 4 ^ the first time I press C-a 5 | 6 the second time I press C-a 

However in Org mode, I would like to use the default function which is org-beginning-of-line. If I use my custom function in Org mode then the point jumps to the beginning of a paragraph instead of the beginning of the line like org-beginning-of-line does.

How can I have my function only activate in non-org buffers? or is there a better way of doing this?

1 Answer 1

1

Just bind that key to what it's normally bound to in Org mode:

(define-key org-mode-map (kbd "C-a") 'org-beginning-of-line) 
2
  • Where do I need to define that? It doesn't seem to override the custom function's behavior. Commented Apr 13, 2023 at 12:57
  • Define it anywhere you like. It just binds that key in the Org-mode keymap. If that doesn't solve the problem then bisect your init file to find some other code that's binding that key to something else in org-mode-map. You can also use describe-keymap for org-mode-map, to see what that key's bound to. Commented Apr 13, 2023 at 15:33

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.