emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Footnote disable & sorting
@ 2012-12-04 22:24 Alan L Tyree
  2012-12-24  1:29 ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Alan L Tyree @ 2012-12-04 22:24 UTC (permalink / raw)
  To: emacs-orgmode

Hi Orgers,

According to the manual,

#+OPTIONS: f:nil

should turn "on/off footnotes like this[1]."

This works for export, but it would be nice if plain footnotes were 
disabled entirely.

My problem is that doing a footnote sort C-u C-C C-X s generates a whole 
lot of unwanted footnotes of the form [2006] etc. All of my footnotes 
are of the form [fn:N], but the aforementioned [2006] appears in 
references to law reports.

Is there some way that "plain" footnotes can be disabled for all purposes?

Thanks for any help.
Alan

-- 
Alan L Tyree                    http://www2.austlii.edu.au/~alan
Tel:  04 2748 6206		sip:172385@iptel.org

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

* Re: Footnote disable & sorting
  2012-12-04 22:24 Footnote disable & sorting Alan L Tyree
@ 2012-12-24  1:29 ` Bastien
  2012-12-24  2:26   ` Alan L Tyree
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2012-12-24  1:29 UTC (permalink / raw)
  To: emacs-orgmode

Hi Alan,

Alan L Tyree <alantyree@gmail.com> 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

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

* Re: Footnote disable & sorting
  2012-12-24  1:29 ` Bastien
@ 2012-12-24  2:26   ` Alan L Tyree
  2012-12-24  9:05     ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Alan L Tyree @ 2012-12-24  2:26 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode


Bastien <bzg@altern.org> writes:

> Hi Alan,
>
> Alan L Tyree <alantyree@gmail.com> 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:172385@iptel.org

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

* Re: Footnote disable & sorting
  2012-12-24  2:26   ` Alan L Tyree
@ 2012-12-24  9:05     ` Bastien
  2012-12-24 19:21       ` Alan L Tyree
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2012-12-24  9:05 UTC (permalink / raw)
  To: Alan L Tyree; +Cc: emacs-orgmode

Hi Alan,

Alan L Tyree <alantyree@gmail.com> 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

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

* Re: Footnote disable & sorting
  2012-12-24  9:05     ` Bastien
@ 2012-12-24 19:21       ` Alan L Tyree
  2012-12-25  3:16         ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Alan L Tyree @ 2012-12-24 19:21 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode


Bastien <bzg@altern.org> writes:

> Hi Alan,
>
> Alan L Tyree <alantyree@gmail.com> 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:172385@iptel.org

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

* Re: Footnote disable & sorting
  2012-12-24 19:21       ` Alan L Tyree
@ 2012-12-25  3:16         ` Bastien
  2012-12-25  5:08           ` Alan L Tyree
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2012-12-25  3:16 UTC (permalink / raw)
  To: Alan L Tyree; +Cc: emacs-orgmode

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

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!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-footnote.el.patch --]
[-- Type: text/x-patch, Size: 3928 bytes --]

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:
 
-nil        prompt the user for each label
-t          create unique labels of the form [fn:1], [fn:2], ...
-confirm    like t, but let the user edit the created value.  In particular,
-           the label can be removed from the minibuffer, to create
-           an anonymous footnote.
+nil        Prompt the user for each label.
+t          Create unique labels of the form [fn:1], [fn:2], etc.
+confirm    Like 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)))
 

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

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

* Re: Footnote disable & sorting
  2012-12-25  3:16         ` Bastien
@ 2012-12-25  5:08           ` Alan L Tyree
  2012-12-25 10:30             ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Alan L Tyree @ 2012-12-25  5:08 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode


Bastien <bzg@altern.org> 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:172385@iptel.org

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

* Re: Footnote disable & sorting
  2012-12-25  5:08           ` Alan L Tyree
@ 2012-12-25 10:30             ` Bastien
  2012-12-25 18:45               ` Alan L Tyree
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2012-12-25 10:30 UTC (permalink / raw)
  To: Alan L Tyree; +Cc: emacs-orgmode

Hi Alan,

Alan L Tyree <alantyree@gmail.com> 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

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

* Re: Footnote disable & sorting
  2012-12-25 10:30             ` Bastien
@ 2012-12-25 18:45               ` Alan L Tyree
  0 siblings, 0 replies; 9+ messages in thread
From: Alan L Tyree @ 2012-12-25 18:45 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode


Bastien <bzg@altern.org> writes:

> Hi Alan,
>
> Alan L Tyree <alantyree@gmail.com> 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:172385@iptel.org

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

end of thread, other threads:[~2012-12-25 18:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-04 22:24 Footnote disable & sorting Alan L Tyree
2012-12-24  1:29 ` Bastien
2012-12-24  2:26   ` Alan L Tyree
2012-12-24  9:05     ` Bastien
2012-12-24 19:21       ` Alan L Tyree
2012-12-25  3:16         ` Bastien
2012-12-25  5:08           ` Alan L Tyree
2012-12-25 10:30             ` Bastien
2012-12-25 18:45               ` Alan L Tyree

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