From mboxrd@z Thu Jan 1 00:00:00 1970 From: Uwe Brauer Subject: Re: add-change-log-entry for orgfiles, header Date: Sat, 15 Oct 2016 09:06:39 +0000 Message-ID: <87insuugkg.fsf@mat.ucm.es> References: <6aa2678d9ffe46a39d83c169e02195a9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> <87a8e626ry.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvKvz-00052y-6f for emacs-orgmode@gnu.org; Sat, 15 Oct 2016 05:07:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvKvu-0001lt-S5 for emacs-orgmode@gnu.org; Sat, 15 Oct 2016 05:07:14 -0400 Received: from [195.159.176.226] (port=56490 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bvKvu-0001h8-Kl for emacs-orgmode@gnu.org; Sat, 15 Oct 2016 05:07:10 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1bvKvW-00062I-AM for emacs-orgmode@gnu.org; Sat, 15 Oct 2016 11:06:46 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org > 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)))