From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: Re: add-change-log-entry for orgfiles, header
Date: Sat, 15 Oct 2016 09:06:39 +0000 [thread overview]
Message-ID: <87insuugkg.fsf@mat.ucm.es> (raw)
In-Reply-To: 87a8e626ry.fsf@ucl.ac.uk
> On Friday, 14 Oct 2016 at 16:58, Uwe Brauer wrote:
> [...]
> Looking at the vc.el code, there is the following comment which may
> allow you to accomplish effectively the same thing although in the
> reverse order (commit and then update changelog)?
> ;; If your site uses the ChangeLog convention supported by Emacs, the
> ;; function `log-edit-comment-to-change-log' could prove a useful checkin hook,
> ;; although you might prefer to use C-c C-a (i.e. `log-edit-insert-changelog')
> ;; from the commit buffer instead or to set `log-edit-setup-invert'.
> (untested)
> but I may have completely misunderstood your question and, if so,
> apologies for the noise!
What you propose is exactly the other way around, first vc-next-action
then insert that log message in the ChangeLog file. But ChangeLog files
got more and more unpopular and are omitted in for example GNU emacs,
they are only used as a tool: first add an entry to ChangeLog (since for
lisp it has nice navigation markers), then insert that entry into the
commit message for vc-next-action.
I want to do the same for org files, using their syntax as navigations
references. Here is the addon for latex to make my point clearer.
Of course it contains a lot of auctex/reftex specific stuff.
Uwe
(defun reftex-add-log-current-defun ()
"Return the current location for add-change-log.
The string will contain information about the section type and title,
the current labeled environment, and the label, if any."
(reftex-access-scan-info)
; (debug)
(save-excursion
;; Check if we should move backward into an environment
(when (and reftex-add-log-use-environment-above
(save-excursion
(re-search-backward "\\\\end{[^} \n\r]+}[ \n\r\t]*\\=" nil t)))
(goto-char (match-beginning 0)))
;; Parse
(let* ((section-start
(save-excursion
(if (re-search-backward reftex-section-regexp nil t)
(match-beginning 1)
nil)))
(macro (if section-start (match-string 2)))
(title (if section-start
(save-match-data
(save-excursion
(goto-char (match-end 0))
(reftex-context-substring)))))
(envs
(cond ((eq reftex-add-log-restrict-environments 'label)
(delq nil
(mapcar (lambda (x)
(if (not (equal (string-to-char (car x)) ?\\))
(car x)))
reftex-env-or-mac-alist)))
((eq reftex-add-log-restrict-environments nil) t)
((listp reftex-add-log-restrict-environments)
reftex-add-log-restrict-environments)
(t t)))
(env-info (reftex-what-environment envs))
(env-info (if (listp (car env-info)) (car env-info) env-info))
(env (if env-info (car env-info)))
(env-start (if env (cdr env-info)))
(env-end
(if env-start
(save-excursion
(goto-char env-start)
(if (re-search-forward (concat "\\end{"
(regexp-quote env)
"}") nil t)
(match-beginning 0)
(point-max)))))
(label
(if env-start
(save-excursion
(goto-char env-start)
(if (re-search-forward "\\label{\\([^}]*\\)}" env-end t)
(match-string 1)
nil))))
(rtn reftex-add-log-format))
;; Cleanup the section title
(while (string-match "[ \t]*\n[ \t]*" title)
(setq title (replace-match " " nil nil title)))
;; Limit the length of the title
(cond ((numberp reftex-add-log-shorten-title)
(let ((n reftex-add-log-shorten-title))
(if (> (length title) n)
(setq title (concat (substring title 0 (- n 3)) "...")))))
((eq reftex-add-log-shorten-title 'abbrev)
(setq title (reftex-abbreviate-title title))))
;; Here we put together the context string for add-log.
;; The following variables contain useful stuff:
(while (string-match " " title)
(setq title (replace-match "_" t t title)))
(while (string-match "%m" rtn)
(setq rtn (replace-match (or macro "") t t rtn)))
(while (string-match "%t" rtn)
(setq rtn (replace-match (or title "") t t rtn)))
(while (string-match "%e" rtn)
(setq rtn (replace-match (or env "") t t rtn)))
(while (string-match "%l" rtn)
(setq rtn (replace-match (or label "") t t rtn)))
;; Return the final string
rtn)))
next prev parent reply other threads:[~2016-10-15 9:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <6aa2678d9ffe46a39d83c169e02195a9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-10-14 17:13 ` add-change-log-entry for orgfiles, header Eric S Fraga
2016-10-15 9:06 ` Uwe Brauer [this message]
[not found] ` <e8e119df4ec14c2196dc4b7f3d49ae51@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-10-15 14:08 ` Eric S Fraga
2016-10-14 16:58 Uwe Brauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87insuugkg.fsf@mat.ucm.es \
--to=oub@mat.ucm.es \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.