Okay, I have a solution. First, special thanks to Nicolas Goaziou for fixing a bug in org-wikinodes
so that CamelCase links will now font-lock under Org-Mode 9.0.7. And a very special thanks to @lawlist for brainstorming this (endlessly) and showing me how to override org-return
.
You'll need to update org-mode
to get Nicolas' fix. Navigate to your ~/.emacs.d
directory and run
git clone git://orgmode.org/org-mode.git
cd org-mode
make autoloads
Then open your init.el
file and add the code to activate org-return-follows-link
and the org-wikinodes
module:
(setq org-return-follows-link t)
(custom-set-variables
'(org-modules (quote (org-wikinodes)))
'(org-return-follows-link t)))
Finally, add this code to override org-return
:
;;; Override org-return
;;; Adds org-wikinode links to work with org-return-follows-link
(with-eval-after-load "org-wikinodes"
(defun org-return (&optional indent)
"Goto next table row or insert a newline.
Calls `org-table-next-row' or `newline', depending on context.
When optional INDENT argument is non-nil, call
`newline-and-indent' instead of `newline'.
When `org-return-follows-link' is non-nil and point is on
a timestamp or a link, call `org-open-at-point'. However, it
will not happen if point is in a table or on a \"dead\"
object (e.g., within a comment). In these case, you need to use
`org-open-at-point' directly."
(interactive)
(let ((context (if org-return-follows-link (org-element-context)
(org-element-at-point))))
(cond
;; In a table, call `org-table-next-row'.
((or (and (eq (org-element-type context) 'table)
(>= (point) (org-element-property :contents-begin context))
(< (point) (org-element-property :contents-end context)))
(org-element-lineage context '(table-row table-cell) t))
(org-table-justify-field-maybe)
(call-interactively #'org-table-next-row))
;; On a link or a timestamp, call `org-open-at-point' if
;; `org-return-follows-link' allows it. Tolerate fuzzy
;; locations, e.g., in a comment, as `org-open-at-point'.
((and org-return-follows-link
(or (org-in-regexp org-ts-regexp-both nil t)
(org-in-regexp org-tsr-regexp-both nil t)
(org-in-regexp org-any-link-re nil t)
;; Adam -- add org-wikinodes to list of regexp types
(and (eq org-wikinodes-active t)
(org-in-regexp org-wikinodes-camel-regexp nil t)
(not (org-at-heading-p)))))
(call-interactively #'org-open-at-point))
;; Insert newline in heading, but preserve tags.
((and (not (bolp))
(save-excursion (beginning-of-line)
(let ((case-fold-search nil))
(looking-at org-complex-heading-regexp))))
;; At headline. Split line. However, if point is on keyword,
;; priority cookie or tags, do not break any of them: add
;; a newline after the headline instead.
(let ((tags-column (and (match-beginning 5)
(save-excursion (goto-char (match-beginning 5))
(current-column))))
(string
(when (and (match-end 4) (org-point-in-group (point) 4))
(delete-and-extract-region (point) (match-end 4)))))
;; Adjust tag alignment.
(cond
((not (and tags-column string)))
(org-auto-align-tags (org-set-tags nil t))
(t (org--align-tags-here tags-column))) ;preserve tags column
(end-of-line)
(org-show-entry)
(if indent (newline-and-indent) (newline))
(when string (save-excursion (insert (org-trim string))))))
;; In a list, make sure indenting keeps trailing text within.
((and indent
(not (eolp))
(org-element-lineage context '(item)))
(let ((trailing-data
(delete-and-extract-region (point) (line-end-position))))
(newline-and-indent)
(save-excursion (insert trailing-data))))
(t (if indent (newline-and-indent) (newline)))))))
org-return
that looks for the face property of your link that is getting cut in half. To see what properties are present, place your cursor on the link and type:C-u C-x =
For example, one of your previous questions needed a new condition for theorg-footnote
face and if it was found, then we calledorg-footnote-action
. In summary, you probably need a new condition that looks for the face and calls whatever action you want if the condition is met. – lawlist Jun 1 '17 at 0:36org-wikinodes
link and ranC- C-x =
. These are the properties: face = org-link, fontified = t, help-echo = "Wiki Link", keymap = [Show], mouse-face = highlight. – Adam Jun 1 '17 at 10:16org-return
has built-in support for theorg-link
face that should triggerorg-open-at-point
. You indicate that akeymap
is present which could trump/supercedeorg-return
if it has been set with a value for the return key. Inasmuch as it should work out-out-of the box, your next step is to do aM-x describe-key
on the Wiki Link and hit the return key and see if you are actually callingorg-return
which is the default behavior inorg-mode
. – lawlist Jun 1 '17 at 16:30M-x describe key
[RET] with point on a wikinodes link yields:RET (translated from <return>) runs the command org-return (found in org-mode-map), which is an interactive compiled Lisp function in ‘org.el’...
– Adam Jun 1 '17 at 17:24emacs -q
and just theorg-wikinodes.el
library with(setq org-return-follows-link t)
– lawlist Jun 1 '17 at 18:46