Re: [O] Footnote disable & sorting
Bastien writes: > Hi Alan, > > Alan L Tyree writes: > >> I'm using the elpa version of org-plus-contrib-20121224. After I learned >> how to apply patches (hangs head in shame!!), it solved all the problems >> that I had - sorting, renumbering, exporting all worked very well. >> >> Are you thinking of making this a general option? > > Yes, sure! Just need to have more time ahead to fix the tests and to > double-check the code. This is fantastic, Bastien. It really makes org even more attractive as an authoring environment, at least for me. Great software! Cheers, Alan -- Alan L Tyree http://www2.austlii.edu.au/~alan Tel: 04 2748 6206 sip:172...@iptel.org
Re: [O] Footnote disable & sorting
Hi Alan, Alan L Tyree writes: > I'm using the elpa version of org-plus-contrib-20121224. After I learned > how to apply patches (hangs head in shame!!), it solved all the problems > that I had - sorting, renumbering, exporting all worked very well. > > Are you thinking of making this a general option? Yes, sure! Just need to have more time ahead to fix the tests and to double-check the code. -- Bastien
Re: [O] Footnote disable & sorting
Bastien writes: > Hi Alan, > > if you can, please test this patch against current maint branch. > All tests don't pass fine, so I'll have to work on this a bit more > but I think it's an improvement, as it doesn't treat [1] as a > footnote when `org-footnote-auto-label' is t (the default.) > > Let me know, thanks! Hi Bastien, I'm using the elpa version of org-plus-contrib-20121224. After I learned how to apply patches (hangs head in shame!!), it solved all the problems that I had - sorting, renumbering, exporting all worked very well. Are you thinking of making this a general option? Thanks so much! Cheers, Alan -- Alan L Tyree http://www2.austlii.edu.au/~alan Tel: 04 2748 6206 sip:172...@iptel.org
Re: [O] Footnote disable & sorting
Hi Alan, if you can, please test this patch against current maint branch. All tests don't pass fine, so I'll have to work on this a bit more but I think it's an improvement, as it doesn't treat [1] as a footnote when `org-footnote-auto-label' is t (the default.) Let me know, thanks! diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index c598965..57ee678 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -67,25 +67,6 @@ (defvar message-cite-prefix-regexp) ; defined in message.el (defvar message-signature-separator) ; defined in message.el -(defconst org-footnote-re - ;; Only [1]-like footnotes are closed in this regexp, as footnotes - ;; from other types might contain square brackets (i.e. links) in - ;; their definition. - ;; - ;; `org-re' is used for regexp compatibility with XEmacs. - (concat "\\[\\(?:" - ;; Match inline footnotes. - (org-re "fn:\\([-_[:word:]]+\\)?:\\|") - ;; Match other footnotes. - "\\(?:\\([0-9]+\\)\\]\\)\\|" - (org-re "\\(fn:[-_[:word:]]+\\)") - "\\)") - "Regular expression for matching footnotes.") - -(defconst org-footnote-definition-re - (org-re "^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]") - "Regular expression matching the definition of a footnote.") - (defconst org-footnote-forbidden-blocks '("ascii" "beamer" "comment" "docbook" "example" "html" "latex" "odt" "src") "Names of blocks where footnotes are not allowed.") @@ -136,13 +117,13 @@ will be used to define the footnote at the reference position." "Non-nil means define automatically new labels for footnotes. Possible values are: -nilprompt the user for each label -t create unique labels of the form [fn:1], [fn:2], ... -confirmlike t, but let the user edit the created value. In particular, - the label can be removed from the minibuffer, to create - an anonymous footnote. +nilPrompt the user for each label. +t Create unique labels of the form [fn:1], [fn:2], etc. +confirmLike t, but let the user edit the created value. + In particular, the label can be removed from the + minibuffer, to create an anonymous footnote. random Automatically generate a unique, random label. -plain Automatically create plain number labels like [1]" +plain Automatically create plain number labels like [1]." :group 'org-footnote :type '(choice (const :tag "Prompt for label" nil) @@ -151,6 +132,36 @@ plain Automatically create plain number labels like [1]" (const :tag "Create a random label" random) (const :tag "Create automatic [N]" plain))) +(defvar org-footnote-re nil + "Regular expression for matching footnotes.") +(defvar org-footnote-definition-re nil + "Regular expression matching the definition of a footnote.") + +(defun org-footnote-set-re () + "Set the regular expression `org-footnote-re'." + ;; Only [1]-like footnotes are closed in this regexp, as footnotes + ;; from other types might contain square brackets (i.e. links) in + ;; their definition. + ;; + ;; `org-re' is used for regexp compatibility with XEmacs. + (setq org-footnote-re + (concat "\\[\\(?:" + ;; Match inline footnotes. + (org-re "fn:\\([-_[:word:]]+\\)?:\\|") + ;; Match other footnotes. + (when (eq org-footnote-auto-label 'plain) + "\\(?:\\([0-9]+\\)\\]\\)\\|") + (org-re "\\(fn:[-_[:word:]]+\\)") + "\\)"))) +(org-footnote-set-re) + +(defun org-footnote-definition-set-re () + (setq org-footnote-definition-re + (if (eq org-footnote-auto-label 'plain) + (org-re "^\\[\\([0-9]+\\)\\]") + (org-re "^\\[\\(fn:[-_[:word:]]+\\)\\]" +(org-footnote-definition-set-re) + (defcustom org-footnote-auto-adjust nil "Non-nil means automatically adjust footnotes after insert/delete. When this is t, after each insertion or deletion of a footnote, @@ -388,7 +399,9 @@ Return a non-nil value when a definition has been found." (cond ((numberp label) (number-to-string label)) ((equal "" label) nil) - ((not (string-match "^[0-9]+$\\|^fn:" label)) + ((not (if (eq org-footnote-auto-label 'plain) + (string-match "^[0-9]+$" label) + (string-match "^fn:" label))) (concat "fn:" label)) (t label))) -- Bastien
Re: [O] Footnote disable & sorting
Bastien writes: > Hi Alan, > > Alan L Tyree writes: > >> Thanks Bastien. > > You're welcome... > >> My real problem is that plain footnotes such as [1930] are a general >> nuisance to me since so many legal citations use that form. I am using a >> hack suggested by Jan Bocker to disable them, perform some operation and >> then "un hack" the hack. > > Sorry to ask the obvious, but from your message I'm not sure you tried > to remove the footnotes from the list of activated links. I'm curious > to know what problem it does not solve for you! > > Thanks for any follow-up, Hi Bastien, Sorry I wasn't clear. I did try removing the footnotes from the list of activated links. My problem is really different: When I try to sort footnotes with C-u C-c C-x f s all my legal citations such as: See Golodetz & Co Inc v Czarnikow-Rionda Co Inc (The Galatia) [1979] 2 Lloyd's Rep 450 produce new footnotes: [1979] DEFINITION NOT FOUND: 1979 As I said, I can live with this thanks to hacks suggested on this list, but it seems that I am always running into the problem in contexts that require new functions or macros. I'm not much of a programmer, but I was looking for some simple way to disable those pesky plain footnotes for *all* purposes. Thanks for you interest in this, and have a good Christmas! Cheers, Alan -- Alan L Tyree http://www2.austlii.edu.au/~alan Tel: 04 2748 6206 sip:172...@iptel.org
Re: [O] Footnote disable & sorting
Hi Alan, Alan L Tyree writes: > Thanks Bastien. You're welcome... > My real problem is that plain footnotes such as [1930] are a general > nuisance to me since so many legal citations use that form. I am using a > hack suggested by Jan Bocker to disable them, perform some operation and > then "un hack" the hack. Sorry to ask the obvious, but from your message I'm not sure you tried to remove the footnotes from the list of activated links. I'm curious to know what problem it does not solve for you! Thanks for any follow-up, -- Bastien
Re: [O] Footnote disable & sorting
Bastien writes: > Hi Alan, > > Alan L Tyree writes: > >> This works for export, but it would be nice if plain footnotes were >> disabled entirely. > > You can set `org-activate-links' so that footnotes are not > recognized as links anymore: > > (setq org-activate-links '(bracket angle plain radio tag date)) > > HTH, Thanks Bastien. My real problem is that plain footnotes such as [1930] are a general nuisance to me since so many legal citations use that form. I am using a hack suggested by Jan Bocker to disable them, perform some operation and then "un hack" the hack. The hack is: replace [ with [ and a non-printing space when [ begins a plain footnote. The trouble is that I need to define new functions or macros for each general footnote operation. I think I misunderstood the purpose of f:nil in the options line. Thanks for your help. Cheers, Alan -- Alan L Tyree http://www2.austlii.edu.au/~alan Tel: 04 2748 6206 sip:172...@iptel.org
Re: [O] Footnote disable & sorting
Hi Alan, Alan L Tyree writes: > This works for export, but it would be nice if plain footnotes were > disabled entirely. You can set `org-activate-links' so that footnotes are not recognized as links anymore: (setq org-activate-links '(bracket angle plain radio tag date)) HTH, -- Bastien