org-emphasis-alist wrongly suggests that you could change the emphasis markers.
No, that is not the case.
It rather gives you the possibility to change the faces for the emphasis markers rigidly given by the syntax specification of org-mode.
Nevertheless, the code below makes some functions of Org-Mode Version 9.2.3 somewhat more general, such that it accepts modifications of the emphasis markers. The modifications are marked by comments starting with ;; Tobias:.
Note, that I used the unspecified third element of the entries of org-emphasis-alist to identify verbatim markers.
(require 'cl-lib)
(require 'org)
(defun org+-emphasis-chars ()
"Return a list (EMPH VERB) of strings of markers.
EMPH is a string containing all marker chars
for non-verbatim emphasis.
VERB is a string containing all marker chars
for verbatim emphasis."
(let (emph verb)
(cl-loop for el in org-emphasis-alist
if (eq (nth 2 el) 'verbatim)
do (push (car el) verb)
else
do (push (car el) emph))
(list
(mapconcat #'identity emph "")
(mapconcat #'identity verb ""))))
(defvar org+-emph-chars ""
"String of characters working as emphasis markers.")
(defvar org+-verb-chars ""
"String of characters working as verbatim markers.")
;; Modified version of org-set-emph-re': (defun org+-set-emph-re (var val) "Set variable and compute the emphasis regular expression." (set var val) (when (and (boundp 'org-emphasis-alist) (boundp 'org-emphasis-regexp-components) org-emphasis-alist org-emphasis-regexp-components) (pcase-let* (((,pre ,post ,border ,body ,nl) org-emphasis-regexp-components)
(body (if (<= nl 0) body
(format "%s?\(?:\n%s?\)\{0,%d\}" body body nl)))
(template
(format (concat "\([%s]\|^\)" ;before markers
"\(\([%%s]\)\([^%s]\|[^%s]%s[^%s]\)\3\)"
"\([%s]\|$\)") ;after markers
pre border border body border post)))
;; Tobias: Added:
(cl-multiple-value-setq (org+-emph-chars org+-verb-chars) (org+-emphasis-chars))
(setq org-emph-re (format template org+-emph-chars)) ;; Tobias: Replaced literal "*+/_"
(setq org-verbatim-re (format template org+-verb-chars))))) ;; Tobias: Replaced literal "~="
(advice-add 'org-set-emph-re :override #'org+-set-emph-re)
(org-set-emph-re 'org-emphasis-alist org-emphasis-alist)
;; Modified version of org-do-emphasis-faces': (defun org+-do-emphasis-faces (limit) "Run through the buffer and emphasize strings." (let ((quick-re (format "\\([%s]\\|^\\)\\([%s%s]\\)" ;; Tobias: modified format string (car org-emphasis-regexp-components) org+-emph-chars ;; Tobias: added org+-verb-chars))) ;; Tobias: added (catch :exit (while (re-search-forward quick-re limit t) (let* ((marker (match-string 2)) (verbatim? (seq-contains org+-verb-chars (string-to-char marker)))) ;; Tobias: replaced (member ... '("=" "~")) (when (save-excursion (goto-char (match-beginning 0)) (and ;; Do not match table hlines. (not (and (equal marker "+") (org-match-line "[ \t]*\\(|[-+]+|?\\|\\+[-+]+\\+\\)[ \t]*$"))) ;; Do not match headline stars. Do not consider ;; stars of a headline as closing marker for bold ;; markup either. (not (and (equal marker "*") (save-excursion (forward-char) (skip-chars-backward "*") (looking-at-p org-outline-regexp-bol)))) ;; Match full emphasis markup regexp. (looking-at (if verbatim? org-verbatim-re org-emph-re)) ;; Do not span over paragraph boundaries. (not (string-match-p org-element-paragraph-separate (match-string 2))) ;; Do not span over cells in table rows. (not (and (save-match-data (org-match-line "[ \t]*|")) (string-match-p "|" (match-string 4)))))) (pcase-let (((,_ ,face ,_) (assoc marker org-emphasis-alist)))
(font-lock-prepend-text-property
(match-beginning 2) (match-end 2) 'face face)
(when verbatim?
(org-remove-flyspell-overlays-in
(match-beginning 0) (match-end 0))
(remove-text-properties (match-beginning 2) (match-end 2)
'(display t invisible t intangible t)))
(add-text-properties (match-beginning 2) (match-end 2)
'(font-lock-multiline t org-emphasis t))
(when org-hide-emphasis-markers
(add-text-properties (match-end 4) (match-beginning 5)
'(invisible org-link))
(add-text-properties (match-beginning 3) (match-end 3)
'(invisible org-link)))
(throw :exit t))))))))
(advice-add 'org-do-emphasis-faces :override #'org+-do-emphasis-faces)
~as a markdown marker? – NickD Nov 21 '21 at 03:04~is interpreted in Org mode files (as a "verbatim" marker). In other modes however (i.e. generally), it is just a tilde: not interpreted at all. So it's not clear what you want to do: have the tilde not interpreted in Org mode files at all? Have you considered not using Org mode on the file? E.g. changing the major mode totext-mode? – NickD Nov 21 '21 at 16:49=as verbatim-marker. So it would be nice to exclude the tilde from being interpreter as marker. – OsunSeyi Nov 21 '21 at 21:46~is for inline code and=for verbatim – OsunSeyi Nov 21 '21 at 23:02org-emphasis-alist, sorry RTFM... – OsunSeyi Nov 21 '21 at 23:54org-verbatim-re.org-set-emph-reis supposed to do so when you setorg-emphasis-alist, but it is buggy in that respect (at least in org-mode 9.3.7). – Tobias Nov 23 '21 at 11:02org-emphasis-alistwith some customization command likecustomize-option. – Tobias Nov 25 '21 at 21:57customize-option, configured there, write toinit.eland restarted Emacs. No success. If I reopencustomize-optionthe changes are still present, but nevertheless they don't have any effect. – OsunSeyi Nov 26 '21 at 13:21