emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Martin Carlé" <mc@aiguphonie.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: [bug] inserting footnotes via org-footnote-action command
Date: Sun, 28 Feb 2016 13:13:19 +0200	[thread overview]
Message-ID: <m1d1rh3x68.fsf@aiguphonie.com> (raw)
In-Reply-To: <878u25d6oh.fsf@nicolasgoaziou.fr>

[-- Attachment #1: Type: text/plain, Size: 7716 bytes --]


On 2016-02-28 Sun 02:23, Nicolas Goaziou wrote:

> Hello,
>
> Martin Carlé <mc@aiguphonie.com> writes:
>
>> Well, I wrapped the exporter mechanism into some advice functions that
>> allow for many different exports from a single file in such a manner that
>> multiple exports are not restricted to subtrees.
>
> Not sure to understand this.

Never mind, I shall explain and release all the hack, if there is more time.

>
>> This extended export mechanism collects sections as marked by tags.
>> This is why, I need to tag the org-footnote-section as well.
>
> Why don't you also collect systematically the footnote section?

Because, tags are a general and convenient way of collecting sections
and I'like to avoid special where ever possible.


All in all, below are the tiny changes I was looking for,
marked in comments as 'hack'.


All best,
mc


  > ,----
  > |                                                                                               
  > | (defun org-footnote--clear-footnote-section ()                                                
  > |   "Remove all footnote sections in buffer and create a new one.                               
  > |                     New section is created at the end of the buffer, before any file          
  > |                     local variable definition.  Leave point within the new section."          
  > |   (when org-footnote-section                                                                  
  > |     (goto-char (point-min))                                                                   
  > |     (let ((regexp                                                                             
  > |            (format org-complex-heading-regexp-format ;; "^\\*+ +%s[ \t]*$"                    
  > |                    (regexp-quote org-footnote-section)))                                      
  > |           tags) ;;; hack                                                                      
  > |       (while (re-search-forward regexp nil t)                                                 
  > |                                                                                               
  > |         ;; ;;; hack                                                                           
  > |         (save-match-data                                                                      
  > |           (save-excursion                                                                     
  > |             (beginning-of-line 1)                                                             
  > |             (looking-at org-todo-line-tags-regexp)                                            
  > |             (when (match-beginning 4)                                                         
  > |               (setq tags (concat " " (buffer-substring (match-beginning 4) (match-end 4)))))))
  > |                                                                                               
  > |         (delete-region                                                                        
  > |          (match-beginning 0)                                                                  
  > |          (progn (org-end-of-subtree t t)                                                      
  > |                 (if (not (eobp)) (point)                                                      
  > |                   (org-footnote--goto-local-insertion-point)                                  
  > |                   (skip-chars-forward " \t\n")                                                
  > |                   (if (eobp) (point) (line-beginning-position))))))                           
  > |       (goto-char (point-max))                                                                 
  > |       (org-footnote--goto-local-insertion-point)                                              
  > |       (when (and (cdr (assq 'heading org-blank-before-new-entry))                             
  > |                  (zerop (save-excursion (org-back-over-empty-lines))))                        
  > |         (insert "\n"))                                                                        
  > |       ;; (insert "* " org-footnote-section "\n")                                              
  > |       (insert "* " org-footnote-section (or tags "") "\n") ;;; hack — the simple way          
  > |     (when tags                                                                                
  > |       (save-excursion                                                                         
  > |         (org-back-to-heading t)                                                               
  > |         (org-set-tags nil 'align))) ;;; hack — the aligned way                                
  > |                                                                                               
  > |     )))                                                                                       
  > |                                                                                               
  > `----

  > ,----
  > |                                                                                                  
  > | (defun org-footnote-create-definition (label)                                                    
  > |   "Start the definition of a footnote with label LABEL.                                          
  > |   Return buffer position at the beginning of the definition.  This                               
  > |   function doesn't move point."                                                                  
  > |   (let ((label (org-footnote-normalize-label label))                                             
  > |         electric-indent-mode)     ; Prevent wrong indentation.                                   
  > |     (org-with-wide-buffer                                                                        
  > |      (cond                                                                                       
  > |       ((not org-footnote-section) (org-footnote--goto-local-insertion-point))                    
  > |       ((save-excursion                                                                           
  > |          (goto-char (point-min))                                                                 
  > |          (re-search-forward                                                                      
  > |           ;; (concat "^\\*+[ \t]+" (regexp-quote org-footnote-section) "[ \t]*$")                
  > |           (format org-complex-heading-regexp-format (regexp-quote org-footnote-section)) ;;; hack
  > |           nil t))                                                                                
  > |        (goto-char (match-end 0))                                                                 
  > |        (forward-line)                                                                            
  > |        (unless (bolp) (insert "\n")))                                                            
  > |       (t (org-footnote--clear-footnote-section)))                                                
  > |      (when (zerop (org-back-over-empty-lines)) (insert "\n"))                                    
  > |      (insert "[fn:" label "] \n")                                                                
  > |      (line-beginning-position 0))))                                                              
  > `----


-- 
Fetch my gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 7E3CA33F

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 805 bytes --]

  reply	other threads:[~2016-02-28 11:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26 17:35 [bug] inserting footnotes via org-footnote-action command Martin Carlé
2016-02-26 21:53 ` Nicolas Goaziou
2016-02-26 22:42   ` Thomas S. Dye
2016-02-26 23:57     ` Nicolas Goaziou
2016-02-27  0:02       ` Thomas S. Dye
2016-02-27  0:37   ` Martin Carlé
2016-02-27  8:16     ` Nicolas Goaziou
2016-02-27 11:12       ` Martin Carlé
2016-02-28  0:23         ` Nicolas Goaziou
2016-02-28 11:13           ` Martin Carlé [this message]
2016-02-28 15:12             ` Nicolas Goaziou

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1d1rh3x68.fsf@aiguphonie.com \
    --to=mc@aiguphonie.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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 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).