Hi Thorsten, Thorsten Jolitz <tjol...@gmail.com> writes:
> This is quite low level and I haven't done anything on this level yet, > but it might be a way to stick with performant constant regexp strings, > but make them more general. That's an idea -- but the one I wanted to explore is this: instead of running Org functions in the current buffer (e.g., an emacs-lisp-mode buffer), the functions would run transparently in a temporary buffer before updating the current one. For example, see this code in `org-open-at-point': ;; Exception n°2: links in comments. ((eq type 'comment) (let ((string-rear (replace-regexp-in-string "^[ \t]*# [ \t]*" "" (buffer-substring (point) (line-beginning-position)))) (string-front (buffer-substring (point) (line-end-position)))) (with-temp-buffer (let ((org-inhibit-startup t)) (org-mode)) (insert value) (goto-char (point-min)) (when (and (search-forward string-rear nil t) (search-forward string-front (line-end-position) t)) (goto-char (match-beginning 0)) (org-open-at-point) (when (string= string-rear "") (forward-char)))))) Obviously, this is a bit fragile and just "good enough" for this defun, but we could generalize it and make it more robust. To illustrate this way of approaching the problem of "using Org in non-Org buffers", consider `org-move-item-up': in an elisp comment, we would copy the comment paragraph at point in `with-temp-buffer', uncomment the buffer, call `org-move-item-up', then comment out the content and send it back to the original buffer as a replacement. I've not studied this idea thoroughly, and this may feels clumsy first, but if it spares us with the need to generalize org-mode to the point that org-mode is not really a separate mode anymore, it might be worst digging into this direction. Hope this is clearer now! -- Bastien