emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* add-change-log-entry for orgfiles, header
@ 2016-10-14 16:58 Uwe Brauer
  0 siblings, 0 replies; 4+ messages in thread
From: Uwe Brauer @ 2016-10-14 16:58 UTC (permalink / raw)
  To: emacs-orgmode

Hi

I have a couple of org files under VC (HG).
For lisp and latex files my workflow is as follows


    -  add-change-log-entry, which adds a nice reference like
    	* emacs_keys.el ([(control super b)]): New:
	(global-set-key [(control super b)] 'ahg-heads)


    -  then call vc-next-action which offers to insert the recent added
       entry of the Changelog file.

    -  Long time ago Carsten Dominik wrote some addons for latex files
       so that references to sections are inserted in a ChangeLog file.

Could there be such an extension for orgmode to get an entry such as
2016-10-14  Uwe Brauer  <oub@mat.ucm.es>

	* remember.org * Sun Sep 25 19:03:04 2016 (HG): undo strip.

Or what ever value the header has.

Regards

Uwe Brauer 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: add-change-log-entry for orgfiles, header
       [not found] <6aa2678d9ffe46a39d83c169e02195a9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2016-10-14 17:13 ` Eric S Fraga
  2016-10-15  9:06   ` Uwe Brauer
       [not found]   ` <e8e119df4ec14c2196dc4b7f3d49ae51@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Eric S Fraga @ 2016-10-14 17:13 UTC (permalink / raw)
  To: emacs-orgmode

On Friday, 14 Oct 2016 at 16:58, Uwe Brauer wrote:

[...]

> Could there be such an extension for orgmode to get an entry such as
> 2016-10-14  Uwe Brauer  <oub@mat.ucm.es>
>
> 	* remember.org * Sun Sep 25 19:03:04 2016 (HG): undo strip.
>

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!

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.2.50.1, Org release_8.3.6-1184-g29830f

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: add-change-log-entry for orgfiles, header
  2016-10-14 17:13 ` Eric S Fraga
@ 2016-10-15  9:06   ` Uwe Brauer
       [not found]   ` <e8e119df4ec14c2196dc4b7f3d49ae51@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Uwe Brauer @ 2016-10-15  9:06 UTC (permalink / raw)
  To: emacs-orgmode


    > 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)))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: add-change-log-entry for orgfiles, header
       [not found]   ` <e8e119df4ec14c2196dc4b7f3d49ae51@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2016-10-15 14:08     ` Eric S Fraga
  0 siblings, 0 replies; 4+ messages in thread
From: Eric S Fraga @ 2016-10-15 14:08 UTC (permalink / raw)
  To: emacs-orgmode

On Saturday, 15 Oct 2016 at 09:06, Uwe Brauer wrote:

[...]

> 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.

Yes, I see.  You want the equivalent that returns, for instance, the
headline under which changes were made?  I cannot help in this case but
I'm sure others could.  Should be a case of invoking a method that finds
the previous headline (maybe recursively)?

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.2.50.1, Org release_8.3.6-1184-g29830f

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-15 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-14 16:58 add-change-log-entry for orgfiles, header Uwe Brauer
     [not found] <6aa2678d9ffe46a39d83c169e02195a9@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-10-14 17:13 ` Eric S Fraga
2016-10-15  9:06   ` Uwe Brauer
     [not found]   ` <e8e119df4ec14c2196dc4b7f3d49ae51@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-10-15 14:08     ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).