[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] Prefer lowercase #+results [9.5.2 (release_9.5.2-3-geb9f34 @ /
From: |
Christopher M. Miles |
Subject: |
Re: [BUG] Prefer lowercase #+results [9.5.2 (release_9.5.2-3-geb9f34 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)] |
Date: |
Thu, 13 Jan 2022 13:25:32 +0800 |
User-agent: |
mu4e 1.7.0; emacs 29.0.50 |
Timothy <tecosaur@gmail.com> writes:
> Hi Christopher,
>
>>> Is there a good reason for this?
>>>
>>> At a glance, I’d personally be tempted to make the use case insensitive, and
>>> only use `org-babel-results-keyword’ when inserting, or remove it all
>>> together.
>>
>> Me too, I hope it can be case-insensitive, if org-mode internal has already
>> case-sensitive
>> processing. I suggest to keep one standard. I remember used to blocks like
>> `#+BEGIN_SRC' etc are
>> uppercase by default. Latter changed into lowercase. Then I did a lot of
>> work to replace them. If we
>> need to use lowercase, I suggest to use them all. It might improve regexp
>> matching speed? Don’t know……
>
> See my reply to Ihor, I actually misread the code. It *is* case insensitive
> (as it
> should be). So, changing the default capitalisation of
> `org-babel-results-keyword'
> would have no effect on the interpretation or function of existing documents.
>
> Based on your comments on converting block case, maybe it would be worth
> providing a function to normalise the case in an Org document?
>
> All the best,
> Timothy
Indeed, there is a similar purpose function:
#+begin_src emacs-lisp
(defun modi/lower-case-org-keywords ()
"Lower case Org keywords and block identifiers.
Example: \"#+TITLE\" -> \"#+title\"
\"#+BEGIN_EXAMPLE\" -> \"#+begin_example\"
Inspiration:
https://code.orgmode.org/bzg/org-mode/commit/13424336a6f30c50952d291e7a82906c1210daf0."
(interactive)
(save-excursion
(goto-char (point-min))
(let ((case-fold-search nil)
(count 0))
;; Match examples: "#+FOO bar", "#+FOO:", "=#+FOO=", "~#+FOO~",
;; "‘#+FOO’", "“#+FOO”", ",#+FOO bar",
;; "#+FOO_bar<eol>", "#+FOO<eol>".
(while (re-search-forward
"\\(?1:#\\+[A-Z_]+\\(?:_[[:alpha:]]+\\)*\\)\\(?:[ :=~’”]\\|$\\)" nil :noerror)
(setq count (1+ count))
(replace-match (downcase (match-string-no-properties 1)) :fixedcase nil
nil 1))
(message "Lower-cased %d matches" count))))
#+end_src
--
[ stardiviner ]
I try to make every word tell the meaning that I want to express.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
signature.asc
Description: PGP signature
- Re: [BUG] Prefer lowercase #+results [9.5.2 (release_9.5.2-3-geb9f34 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)], (continued)
Re: [BUG] Prefer lowercase #+results [9.5.2 (release_9.5.2-3-geb9f34 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)], Christopher M. Miles, 2022/01/12
Re: [BUG] Prefer lowercase #+results [9.5.2 (release_9.5.2-3-geb9f34 @ /Users/salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/org/)], Ihor Radchenko, 2022/01/13