From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id YNm9HGlLNWJYcQEAgWs5BA (envelope-from ) for ; Sat, 19 Mar 2022 04:18:01 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id AJgbGmlLNWJJtQAA9RJhRA (envelope-from ) for ; Sat, 19 Mar 2022 04:18:01 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C19EC2E7 for ; Sat, 19 Mar 2022 04:18:00 +0100 (CET) Received: from localhost ([::1]:43816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVPbL-0008Jr-5C for larch@yhetil.org; Fri, 18 Mar 2022 23:17:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVPae-0008Jg-U0 for emacs-orgmode@gnu.org; Fri, 18 Mar 2022 23:17:16 -0400 Received: from [2a00:1450:4864:20::335] (port=54268 helo=mail-wm1-x335.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVPac-0005Ag-NG for emacs-orgmode@gnu.org; Fri, 18 Mar 2022 23:17:16 -0400 Received: by mail-wm1-x335.google.com with SMTP id 185so931968wmc.3 for ; Fri, 18 Mar 2022 20:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=FxI2+dKRFef0I2XYm/YeKl8RqAJm/JRvaCmeczSFSiE=; b=fWh7IPtG0EMMeTHl9IKKHgUboVEQ4xFHc9Nz6Lieg0+K1crdEAkMAF4tCqLQWuD3Ar MfbfDYY7rNsHKDJtD5Bz4If1dpsIpJ2+rKXwjUxLRh073iDPwyfv7aGJLiykLrfEjJVw MyvPjm7hd58LVN5fw/CU+vPPy4q2NwLUcqxaS3Bp590QGIVGvxnXeTIM3ufOaqXpuh+9 Mqveul7rKZcpOnkik1nCSFLkx4nERv7NUx6BXMc3Qq/oxD20hnLAM1Qor7292ZHmzi2F c4r3TxfefMBHl2WRbV3T47e0il5QqdoUvmDRLeUy89sxZGDmhqCOQR6cjOSorOKjTx+A Lbwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=FxI2+dKRFef0I2XYm/YeKl8RqAJm/JRvaCmeczSFSiE=; b=h9HXAhtN+1W8J64pOldes7KJgutkeeY4I664KJgqLxRQNhKbCOSXObY1zJb7R2GxAr K6VKydyubFrOh5wfV5BXDH55GCYF5nVXzCejJgD3d6ztGDnj3a33ol4p/wwZVk96oapm /Y+45O16gtXNBEbVkdl8PWCvHjNt8FRzGLgQsWRhp9qHjlzf1R7yDCrDUUEomkn/Cedv JJBp1kYojBKqCddXGmFVTiMqXFTb9Y84ALSUVRM6yK7vTdfLImTC2X31fQKtbT6NIbXf KxZMFHtab+ufwt6xuyziXA/czWnUBP+n6VGXY7m79Z3CijhH7jSIUIlyvdhFycbfYY82 wzYQ== X-Gm-Message-State: AOAM533ZW0cf5JKEH9chc3aXwS4LNuWITsCDG9ExYuZWN+encKM/uVUk 1nhUq3MWro+/aA1a9fADtkgDUe+RHMI= X-Google-Smtp-Source: ABdhPJwmyJE4D2SWBO6u8ycgsJMxMuZ1u2pd123JcSNXRGs0lzRyVhcyCDahbiDAEhS8A3v8QodTBA== X-Received: by 2002:a05:600c:6001:b0:38c:6c43:4427 with SMTP id az1-20020a05600c600100b0038c6c434427mr10517177wmb.186.1647659832305; Fri, 18 Mar 2022 20:17:12 -0700 (PDT) Received: from pluto.localnet (aaubervilliers-654-1-6-220.w83-200.abo.wanadoo.fr. [83.200.23.220]) by smtp.gmail.com with ESMTPSA id s2-20020a1cf202000000b0038977146b28sm8067814wmc.18.2022.03.18.20.17.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Mar 2022 20:17:11 -0700 (PDT) From: chris To: orgmode Subject: Re: Using backticks for the inline code delimeter? Date: Sat, 19 Mar 2022 04:17:10 +0100 Message-ID: <4396644.LvFx2qVVIh@pluto> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="nextPart2244150.ElGaqSPkdT" Content-Transfer-Encoding: 7Bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::335 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=inkbottle007@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1647659881; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=FxI2+dKRFef0I2XYm/YeKl8RqAJm/JRvaCmeczSFSiE=; b=DyqdXoq7VVISxdv/BxAH7MgaF9vPqWjY8XkTXndWIT9lvHdx6ieblSDjHgVfEDR03NbS7N J7oKwG3O3U3oVxQM883OVbdUuNyJeLqLATEUDEc4xsz9utQnVPYNWUg0XuM/aIzHg6X3sO YE+ltjkBO5G4u0qM3J0/VdggBadInlFr/zT924Nwuc9zzmmyysT0uX0NtObU6Wl5mnj1oh aK66CFNtwfKn9k0FoDrjnlUI9iVHV5Mi2CD7iZA8rukhjszH9iGlQqKdEoQGLFYJtOVpHW 0xysSJ2vik+Q+jekvZj1G3Z8A3p09dKa/C8b4mZHkhmZLecvsJEei4CeqjCoYA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1647659881; a=rsa-sha256; cv=none; b=sFsz4AWqLbHCxRUAPNRneh3z+8pdEYoRAEXyADTkwN8puf8iFqnFwwsjsSusmRhpfTMR7o rEGOAwt/wV+PkgVKG96/3ldnnPDyb8ASj7khKGqmZkWQgzIcbx7Px/2LiEP7AjXdwzkyk4 VMLgz8Rjd/X5P4ZPccTmttKI2Jz/YV2478N2WaWcsQ3UaHlvVqIj2Nu/DW7HG0Gfe2z+YM 8nhTiVzPMIhbPfOGTKvLyWhCtsOob9A3BzZB7kVaZkV6bZQcnUpB//czWBwmHHAQ6q6a/T HDP8kmhybvfwAhJWpTRJNFVLwrBKiZXaVYWFQT+lZIOzFHuqbPGXMU5yvbTk0w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fWh7IPtG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -5.14 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fWh7IPtG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: C19EC2E7 X-Spam-Score: -5.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: xiLZQIBisDi8 This is a multi-part message in MIME format. --nextPart2244150.ElGaqSPkdT Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" > George Mauer writes: >> is there a straightforward way to extend the org parser to do this? > I don't think so. It seems the emphasis markers are hard-coded > in various places. > > From a quick look at the code, you'd have to customize > `org-emphasis-alist` and redefine `org-set-emph-re` and > `org-do-emphasis-faces`. Maybe that'd be enough. > I did just what you said, and I've inserted what's bellow, somewhere in my `init.org` / `init.el`, before anything `org-mode` related (save for two `hook`): (Note it is an almost exact copy from `org.el`, I've only changed a few characters. And added the `advice-add override`.) #+begin_src emacs-lisp (defun org-set-emph-re-fixed (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))) (setq org-emph-re (format template "*/_+")) (setq org-verbatim-re (format template "=~`"))))) (advice-add 'org-set-emph-re :override #'org-set-emph-re-fixed) #+end_src #+begin_src emacs-lisp (defun org-do-emphasis-faces-fixed (limit) "Run through the buffer and emphasize strings." (let ((quick-re (format "\\([%s]\\|^\\)\\([~`=*/_+]\\)" (car org-emphasis-regexp-components)))) (catch :exit (while (re-search-forward quick-re limit t) (let* ((marker (match-string 2)) (verbatim? (member marker '("~" "`" "=")))) (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)) (m (if org-hide-emphasis-markers 4 2))) (font-lock-prepend-text-property (match-beginning m) (match-end m) '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 (and org-hide-emphasis-markers (not (org-at-comment-p))) (add-text-properties (match-end 4) (match-beginning 5) '(invisible t)) (add-text-properties (match-beginning 3) (match-end 3) '(invisible t))) (throw :exit t)))))))) --nextPart2244150.ElGaqSPkdT Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="UTF-8"

> George Mauer writes:

>= ;> is there a straightforward way to extend the org parser to do this?

>= ; I don't think so. It seems the emphasis markers are hard-coded

>= ; in various places.

>= ;

>= ; From a quick look at the code, you'd have to customize

>= ; `org-emphasis-alist` and redefine `org-set-emph-re`  and

>= ; `org-do-emphasis-faces`. Maybe that'd be enough.

>= ;


I did just what you said, and I've inserted what's bellow, somewhere in = my `init.org` / `init.el`, before anything `org-mode` related (save for two= `hook`):

(No= te it is an almost exact copy from `org.el`, I've only changed a few charac= ters. And added the `advice-add override`.)


#+begin_src emacs-lisp

&nb= sp; (defun org-set-emph-re-fixed (var val)

&nb= sp;   "Set variable and compute the emphasis regular express= ion."

&nb= sp;   (set var val)

&nb= sp;   (when (and (boundp 'org-emphasis-alist)

&nb= sp;            =   (boundp 'org-emphasis-regexp-components)

&nb= sp;            =   org-emphasis-alist org-emphasis-regexp-components)

&nb= sp;     (pcase-let*

&nb= sp;         ((`(,pre ,post ,border = ,body ,nl) org-emphasis-regexp-components)

&nb= sp;          (body (if (<= =3D nl 0) body

&nb= sp;            =       (format "%s*?\\(?:\n%s*?\\)\\{0,%d\\}&q= uot; body body nl)))

&nb= sp;          (template

&nb= sp;           (format (co= ncat "\\([%s]\\|^\\)" ;before markers

&nb= sp;            =             &nb= sp;  "\\(\\([%%s]\\)\\([^%s]\\|[^%s]%s[^%s]\\)\\3\\)"

&nb= sp;            =             &nb= sp;  "\\([%s]\\|$\\)") ;after markers

&nb= sp;            =        pre border border body border post)))<= /p>

&nb= sp;       (setq org-emph-re (format template = "*/_+"))

&nb= sp;       (setq org-verbatim-re (format templ= ate "=3D~`")))))


  (advice-add 'org-set-emph-re :override #'org-set-emph-re-fixed)

#+e= nd_src


#+begin_src emacs-lisp

&nb= sp; (defun org-do-emphasis-faces-fixed (limit)

&nb= sp;   "Run through the buffer and emphasize strings."

&nb= sp;   (let ((quick-re (format "\\([%s]\\|^\\)\\([~`=3D*/_+]\= \)"

&nb= sp;            =             &nb= sp;  (car org-emphasis-regexp-components))))

&nb= sp;     (catch :exit

&nb= sp;       (while (re-search-forward quick-re = limit t)

&nb= sp;         (let* ((marker (match-s= tring 2))

&nb= sp;            =     (verbatim? (member marker '("~" "`" = "=3D"))))

&nb= sp;           (when (save= =2Dexcursion

&nb= sp;            =        (goto-char (match-beginning 0))

&nb= sp;            =        (and

&nb= sp;            =         ;; Do not match table hlines.

&nb= sp;            =         (not (and (equal marker "+&= quot;)

&nb= sp;            =             &nb= sp;     (org-match-line

&nb= sp;            =             &nb= sp;      "[ \t]*\\(|[-+]+|?\\|\\+[-+]+\\+\\)[= \t]*$")))

&nb= sp;            =         ;; Do not match headline stars.&= nbsp; Do not consider

&nb= sp;            =         ;; stars of a headline as closin= g marker for bold

&nb= sp;            =         ;; markup either.

&nb= sp;            =         (not (and (equal marker "*&= quot;)

&nb= sp;            =             &nb= sp;     (save-excursion

&nb= sp;            =             &nb= sp;       (forward-char)

&nb= sp;            =             &nb= sp;       (skip-chars-backward "*")=

&nb= sp;            =             &nb= sp;       (looking-at-p org-outline-regexp-bo= l))))

&nb= sp;            =         ;; Match full emphasis markup re= gexp.

&nb= sp;            =         (looking-at (if verbatim? org-ve= rbatim-re org-emph-re))

&nb= sp;            =         ;; Do not span over paragraph bo= undaries.

&nb= sp;            =         (not (string-match-p org-element= =2Dparagraph-separate

&nb= sp;            =             &nb= sp;            =     (match-string 2)))

&nb= sp;            =         ;; Do not span over cells in tab= le rows.

&nb= sp;            =         (not (and (save-match-data (org-= match-line "[ \t]*|"))

&nb= sp;            =             &nb= sp;     (string-match-p "|" (match-string 4))= ))))

&nb= sp;            = (pcase-let ((`(,_ ,face ,_) (assoc marker org-emphasis-alist))

&nb= sp;            =              (m= (if org-hide-emphasis-markers 4 2)))

&nb= sp;            =    (font-lock-prepend-text-property

&nb= sp;            =     (match-beginning m) (match-end m) 'face face)

&nb= sp;            =    (when verbatim?

&nb= sp;            =      (org-remove-flyspell-overlays-in

&nb= sp;            =       (match-beginning 0) (match-end 0))

&nb= sp;            =      (remove-text-properties (match-beginning 2) (match= =2Dend 2)

&nb= sp;            =             &nb= sp;            =     '(display t invisible t intangible t)))

&nb= sp;            =    (add-text-properties (match-beginning 2) (match-end 2)

&nb= sp;            =             &nb= sp;           '(font-lock= =2Dmultiline t org-emphasis t))

&nb= sp;            =    (when (and org-hide-emphasis-markers

&nb= sp;            =             &nb= sp; (not (org-at-comment-p)))

&nb= sp;            =      (add-text-properties (match-end 4) (match-beginnin= g 5)

&nb= sp;            =             &nb= sp;            = '(invisible t))

&nb= sp;            =      (add-text-properties (match-beginning 3) (match-en= d 3)

&nb= sp;            =             &nb= sp;            = '(invisible t)))

&nb= sp;            =    (throw :exit t))))))))



  (advice-add 'org-do-emphasis-faces :override #'org-do-empha= sis-faces-fixed)

#+e= nd_src


#+begin_src emacs-lisp

&nb= sp; (custom-set-variables '(org-emphasis-alist

&nb= sp;            =             &nb= sp; '(("*" bold)

&nb= sp;            =             &nb= sp;   ("/" italic)

&nb= sp;            =             &nb= sp;   ("_" underline)

&nb= sp;            =             &nb= sp;   ("=3D" org-verbatim verbatim)

&nb= sp;            =             &nb= sp;   ("`" org-code verbatim)

&nb= sp;            =             &nb= sp;   ("~" org-code verbatim)

&nb= sp;            =             &nb= sp;   ("+" (:strike-through t)))))

#+e= nd_src


Just before:


#+begin_src emacs-lisp

&nb= sp; (straight-use-package 'org)

#+e= nd_src


And it seems it works.


I've tried the "cosmetic" version from bellow, but it wasn't w= orking so well, with either `visual-fill-colum` or `org-indent-mode`?

Wel= l, it wasn't working well. I don't know if the hack above is playing more n= icely. Because I've only tested it on one example.

Chr= is


>

>= ; For the cosmetic part, there's this  piece of code from

>= ; https://archive.casouri.cat/note/2020/better-looking-verbatim-markup-in-o= rg-mode/index.html

>= ; that displays org's `=3D` and `~` markers as ```.

>= ;

>= ; --

>= ; S=C3=A9bastien Miquel


--nextPart2244150.ElGaqSPkdT--