From de2274bc394d88103b5af262691772a7cfedce4b Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sun, 19 Jul 2020 23:41:20 +0200 Subject: [PATCH] Org follow links on "RET" key --- .emacs.d/config.org | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.emacs.d/config.org b/.emacs.d/config.org index 3f5663b..e490310 100644 --- a/.emacs.d/config.org +++ b/.emacs.d/config.org @@ -728,7 +728,7 @@ Functions that only use built-in Emacs functionality. "Hide default startup message." (message "")) - (defun dot/describe-symbol-at-point (&optional SYMBOL) + (defun dot/describe-symbol-at-point (&optional symbol) "Display the full documentation of SYMBOL at point. Will show the info of SYMBOL as a function, variable, and/or face." (interactive "P") @@ -742,6 +742,19 @@ Functions that only use built-in Emacs functionality. (save-excursion (indent-region (point-min) (point-max) nil))) + (defun dot/org-ret-at-point () + "Org return key at point. + + If point is on: + link -- follow it + otherwise -- run the default (evil-ret) expression" + (interactive) + (let ((type (org-element-type (org-element-context)))) + (pcase type + ('link (org-open-at-point)) + (_ (evil-ret)) + ))) + (defun split-follow-horizontally () "Split and follow window." (interactive) @@ -1005,10 +1018,9 @@ Set custom keybinds to functionality of custom packages. (with-eval-after-load 'evil-states (general-define-key :keymaps 'evil-normal-state-map - - ;; Neotree "C-n" 'neotree-toggle-in-project-root) + ;; Neotree (general-define-key :states 'normal :keymaps 'neotree-mode-map @@ -1038,6 +1050,12 @@ Set custom keybinds to functionality of custom packages. "r" 'dashboard-goto-recent-files ) + ;; Org + (general-define-key + :states 'normal + :keymaps 'org-mode-map + "RET" 'dot/org-ret-at-point) + ;; Elfeed (general-define-key :states 'normal @@ -1215,6 +1233,8 @@ https://github.com/suyashbire1/emacs.d/blob/master/init.el (local-leader org-mode-map "'" '(org-edit-special :which-key "Org edit") "c" '(org-edit-special :which-key "Org edit") + "l" '(org-insert-link :which-key "Org make link") + "o" '(org-open-at-point :which-key "Org open at point") ) (local-leader org-src-mode-map