emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Rename headline to heading


From: André A . Gomes
Subject: Re: [PATCH] Rename headline to heading
Date: Fri, 15 Oct 2021 13:18:38 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Timothy <tecosaur@gmail.com> writes:

> I haven’t gone through the patches you’ve sent, but it looks like you’ve put a
> tremendous amount of effort into this! It’s fantastic to see. I think I can
> speak for the Org community when I say thank you.

I appreciate the kind words.  It's my pleasure to collaborate with the
community.  Let me stress the fact that it's my first contribution and
I'm not comfortable with the codebase, so I feedback is welcome :)

It actually took me less time than it may look like, since I used many
"tricks" like keyboard macros, registers, etc.  I even wrote some utils,
and it got me thinking about some Elisp tangential aspects.  For
instance, I realised it's hard to query-replace sexps' docstrings.
And no, I don't want to use multi-line regex (PCRE).  It's the wrong
tool IMO.  My "solution" is also poor, but for other reasons.  

--8<---------------cut here---------------start------------->8---
;; this is brittle.  for example, when there's a string as a value
;; before the actual docstring!
(defun query-replace-docstring-sexp (sexp-symbol from-string to-string)
  (save-excursion
    (do ((point (scan-lists (point-max) -1 0)
                (scan-lists (point) -1 0)))
        ((null point))
      (goto-char point)
      (save-excursion
        (let ((point-max-sexp (scan-sexps point 1)))
          (when (and (search-forward (concat "(" (symbol-name sexp-symbol))
                                     point-max-sexp t)
                     (search-forward "\"" point-max-sexp t))
            (query-replace from-string
                           to-string
                           t
                           (prog2 (backward-char) (point))
                           ;; the sexp here is the string enclosed by \"
                           (scan-sexps (point) 1))))))))
--8<---------------cut here---------------end--------------->8---


This is off-topic anyway.  My point is that there are ALWAYS interesting
things to do in any seemingly "boring" task.


--
André A. Gomes
"Free Thought, Free World"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]