emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Latex: exporting a tree
@ 2010-12-09  9:02 Jörg Hagmann
  2010-12-10 14:49 ` Jörg Hagmann
  0 siblings, 1 reply; 12+ messages in thread
From: Jörg Hagmann @ 2010-12-09  9:02 UTC (permalink / raw)
  To: Emacs-orgmode

Dear list,

With today's pull, exporting a subtree to latex (C-cC-e 1 l) truncates a 
table at the horizontal line and eliminates the text between the table 
and the next heading. It works when exporting the whole file (C-cC-e l).

-------Minimal example--------------
* Test
   :PROPERTIES:
   :COLUMNS: %15ITEM(Lecture) %number %Date %hours{+} %status{X/}
   :status_ALL: "[ ]" "[X]"
   :END:

#+BEGIN: columnview :hlines 1 :id local :maxlevel 2
| Lecture |   number | Date                         | hours | status |
|---------+----------+------------------------------+-------+--------|
| * Test  |          |                              |     2 | [0/1]  |
| ** One  | 16.1.7.1 | [2010-12-13 Mon 10:15-12:00] |     2 | [ ]    |
#+END:

Some text

** One
    :PROPERTIES:
    :Date: [2010-12-13 Mon 10:15-12:00]
    :hours: 2
    :number: 16.1.7.1
    :status:   [ ]
    :END:
---------End of minimal example---------------

Regards, Jörg

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

* Re: Latex: exporting a tree
  2010-12-09  9:02 Latex: exporting a tree Jörg Hagmann
@ 2010-12-10 14:49 ` Jörg Hagmann
  2010-12-15 10:04   ` Jörg Hagmann
  0 siblings, 1 reply; 12+ messages in thread
From: Jörg Hagmann @ 2010-12-10 14:49 UTC (permalink / raw)
  To: emacs-orgmode

I checked the problem below with the latest (7.4 alias "7.3") version 
and it is still there.
Could somebody look into that?
Emacs 23.2 on OS X 10.6.5

Thanks, Jörg
> With today's pull, exporting a subtree to latex (C-cC-e 1 l) truncates 
> a table at the horizontal line and eliminates the text between the 
> table and the next heading. It works when exporting the whole file 
> (C-cC-e l).
>
> -------Minimal example--------------
> * Test
>   :PROPERTIES:
>   :COLUMNS: %15ITEM(Lecture) %number %Date %hours{+} %status{X/}
>   :status_ALL: "[ ]" "[X]"
>   :END:
>
> #+BEGIN: columnview :hlines 1 :id local :maxlevel 2
> | Lecture |   number | Date                         | hours | status |
> |---------+----------+------------------------------+-------+--------|
> | * Test  |          |                              |     2 | [0/1]  |
> | ** One  | 16.1.7.1 | [2010-12-13 Mon 10:15-12:00] |     2 | [ ]    |
> #+END:
>
> Some text
>
> ** One
>    :PROPERTIES:
>    :Date: [2010-12-13 Mon 10:15-12:00]
>    :hours: 2
>    :number: 16.1.7.1
>    :status:   [ ]
>    :END:
> ---------End of minimal example--------------- 

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

* Re: Latex: exporting a tree
  2010-12-10 14:49 ` Jörg Hagmann
@ 2010-12-15 10:04   ` Jörg Hagmann
  2010-12-15 11:41     ` Carsten Dominik
  2010-12-15 11:45     ` BUG " Giovanni Ridolfi
  0 siblings, 2 replies; 12+ messages in thread
From: Jörg Hagmann @ 2010-12-15 10:04 UTC (permalink / raw)
  To: emacs-orgmode

Third attempt to get your attention:

- If you export the (new) minimal example below to latex (C-cC-e l), it 
works.
- If you only export a tree (Subtree in the example; C-cC-e 1 l), the 
first table ends at the horizontal line and everything between it and 
the next node (Subsubtree) is eliminated. The second (identical) table 
is exported correctly.
- If you remove the asterisk(s) in the first table, it works.

This problem crept in in the last days or weeks before 7.4.

It may not be a problem for most of you, but I happen to have a number 
of files where columns are automatically displayed as tables preceding 
the first subnode (#+BEGIN: columnview ...). An alternative would be to 
display %ITEM in column-view without the asterisks.

Emacs 23.2.1 on OS X 10.6.5
Org-mode version 7.4 (release_7.4.24.g48b11.dirty)

Thanks, Jörg

-------New minimal example------------
* Subtree


| One    | Two  | Three |
|--------+------+-------|
| * Test | text | text  |
| ** One | text | text  |


Some text

** Subsubtree

| One    | Two  | Three |
|--------+------+-------|
| * Test | text | text  |
| ** One | text | text  |

--------End of new minimal example---------------------

On 12/10/10 3:49 PM, Jörg Hagmann wrote:
> I checked the problem below with the latest (7.4 alias "7.3") version 
> and it is still there.
> Could somebody look into that?
> Emacs 23.2 on OS X 10.6.5
>
> Thanks, Jörg
>> With today's pull, exporting a subtree to latex (C-cC-e 1 l) 
>> truncates a table at the horizontal line and eliminates the text 
>> between the table and the next heading. It works when exporting the 
>> whole file (C-cC-e l).
>>
>> -------Minimal example--------------
>> * Test
>>   :PROPERTIES:
>>   :COLUMNS: %15ITEM(Lecture) %number %Date %hours{+} %status{X/}
>>   :status_ALL: "[ ]" "[X]"
>>   :END:
>>
>> #+BEGIN: columnview :hlines 1 :id local :maxlevel 2
>> | Lecture |   number | Date                         | hours | status |
>> |---------+----------+------------------------------+-------+--------|
>> | * Test  |          |                              |     2 | [0/1]  |
>> | ** One  | 16.1.7.1 | [2010-12-13 Mon 10:15-12:00] |     2 | [ ]    |
>> #+END:
>>
>> Some text
>>
>> ** One
>>    :PROPERTIES:
>>    :Date: [2010-12-13 Mon 10:15-12:00]
>>    :hours: 2
>>    :number: 16.1.7.1
>>    :status:   [ ]
>>    :END:
>> ---------End of minimal example--------------- 

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

* Re: Latex: exporting a tree
  2010-12-15 10:04   ` Jörg Hagmann
@ 2010-12-15 11:41     ` Carsten Dominik
  2010-12-15 12:13       ` Nicolas Goaziou
  2010-12-15 11:45     ` BUG " Giovanni Ridolfi
  1 sibling, 1 reply; 12+ messages in thread
From: Carsten Dominik @ 2010-12-15 11:41 UTC (permalink / raw)
  To: Jörg Hagmann; +Cc: Nicolas Goaziou, Org Mode

Hi Jörg,

On Dec 15, 2010, at 11:04 AM, Jörg Hagmann wrote:

> Third attempt to get your attention:

why the impatience?  Your first attempt was December 9, now it is  
December 15...
No-one is being payed here for fixing problems.

>
> - If you export the (new) minimal example below to latex (C-cC-e l),  
> it works.
> - If you only export a tree (Subtree in the example; C-cC-e 1 l),  
> the first table ends at the horizontal line and everything between  
> it and the next node (Subsubtree) is eliminated. The second  
> (identical) table is exported correctly.
> - If you remove the asterisk(s) in the first table, it works.

Thank you for your report, this issue is fixed now.

Nicolas, I believe this was one of your patches - the limited outline  
regexp needs to be anchored in the way you use it in org-latex.el.

Greetings

- Carsten

>
> This problem crept in in the last days or weeks before 7.4.
>
> It may not be a problem for most of you, but I happen to have a  
> number of files where columns are automatically displayed as tables  
> preceding the first subnode (#+BEGIN: columnview ...). An  
> alternative would be to display %ITEM in column-view without the  
> asterisks.
>
> Emacs 23.2.1 on OS X 10.6.5
> Org-mode version 7.4 (release_7.4.24.g48b11.dirty)
>
> Thanks, Jörg
>
> -------New minimal example------------
> * Subtree
>
>
> | One    | Two  | Three |
> |--------+------+-------|
> | * Test | text | text  |
> | ** One | text | text  |
>
>
> Some text
>
> ** Subsubtree
>
> | One    | Two  | Three |
> |--------+------+-------|
> | * Test | text | text  |
> | ** One | text | text  |
>
> --------End of new minimal example---------------------
>
> On 12/10/10 3:49 PM, Jörg Hagmann wrote:
>> I checked the problem below with the latest (7.4 alias "7.3")  
>> version and it is still there.
>> Could somebody look into that?
>> Emacs 23.2 on OS X 10.6.5
>>
>> Thanks, Jörg
>>> With today's pull, exporting a subtree to latex (C-cC-e 1 l)  
>>> truncates a table at the horizontal line and eliminates the text  
>>> between the table and the next heading. It works when exporting  
>>> the whole file (C-cC-e l).
>>>
>>> -------Minimal example--------------
>>> * Test
>>>  :PROPERTIES:
>>>  :COLUMNS: %15ITEM(Lecture) %number %Date %hours{+} %status{X/}
>>>  :status_ALL: "[ ]" "[X]"
>>>  :END:
>>>
>>> #+BEGIN: columnview :hlines 1 :id local :maxlevel 2
>>> | Lecture |   number | Date                         | hours |  
>>> status |
>>> |---------+----------+------------------------------+------- 
>>> +--------|
>>> | * Test  |          |                              |     2 |  
>>> [0/1]  |
>>> | ** One  | 16.1.7.1 | [2010-12-13 Mon 10:15-12:00] |     2 |  
>>> [ ]    |
>>> #+END:
>>>
>>> Some text
>>>
>>> ** One
>>>   :PROPERTIES:
>>>   :Date: [2010-12-13 Mon 10:15-12:00]
>>>   :hours: 2
>>>   :number: 16.1.7.1
>>>   :status:   [ ]
>>>   :END:
>>> ---------End of minimal example---------------
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: BUG Latex: exporting a tree
  2010-12-15 10:04   ` Jörg Hagmann
  2010-12-15 11:41     ` Carsten Dominik
@ 2010-12-15 11:45     ` Giovanni Ridolfi
  2010-12-15 11:53       ` Giovanni Ridolfi
  1 sibling, 1 reply; 12+ messages in thread
From: Giovanni Ridolfi @ 2010-12-15 11:45 UTC (permalink / raw)
  To: Jörg Hagmann; +Cc: emacs-orgmode

Jörg Hagmann <joerg.hagmann@unibas.ch> writes:

> Third attempt to get your attention:
>

I confirm the bug.

GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600) of 2010-05-08 on G41R2F1
Org-mode version 7.4 commit-eb0d35dd185043933a0415222adc51906579dc67


> - If you export the (new) minimal example below to latex (C-cC-e l),
>   it works.
 -------New minimal example------------
* Subtree 

| One    | Two  | Three |
|--------+------+-------|
| * Test | text | text  |
| ** One | text | text  |

Some text, subtree 1

** Subsubtree 

| One  2 | Two 2  | Three 2 |
|--------+------+-------|
| * Test 2 | text 2 | text 2  |
| ** One 2 | text 2 | text 2  |
--------End of new minimal example---------------------


> - If you only export a tree (Subtree in the example; C-c C-e 1 l), 
> the 
> first table ends at the horizontal line and everything between it and
> the next node (Subsubtree) is eliminated. 
> The second (identical) table  is exported correctly.

this happens also if it is manually selected the region between  
"* Subtree " and "subtree 1" and exported with C-c C-e

The html export works ok.

> - If you remove the asterisk(s) in the first table, it works.

Actually,  it works *only* for the lines without "*"
----------------------------------example: --------
* Subtree 

| One    | Two  | Three |
|--------+------+-------|
| Test   | text | text  |
| ** One | text | text  |

Some text, subtree 1
-----------------------------------------
Is exported as:

\begin{center}
\begin{tabular}{lll}
 One   &  Two   &  Three  \\
\hline
 Test  &  text  &  text   \\
\end{tabular}
\end{center}
\section{Subsubtree}

the second line "** One ...." is not exported.
>
> This problem crept in in the last days or weeks before 7.4.


> Emacs 23.2.1 on OS X 10.6.5
> Org-mode version 7.4 (release_7.4.24.g48b11.dirty)

cheers,
Giovanni

P.S. 
Jörg in the meanwhile you may write a function, to post-process your
column-view, that 
either deletes "*"
or 
substitutes "| * <- space" with "| "

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

* Re: BUG Latex: exporting a tree
  2010-12-15 11:45     ` BUG " Giovanni Ridolfi
@ 2010-12-15 11:53       ` Giovanni Ridolfi
  0 siblings, 0 replies; 12+ messages in thread
From: Giovanni Ridolfi @ 2010-12-15 11:53 UTC (permalink / raw)
  To: emacs-orgmode

Giovanni Ridolfi <giovanni.ridolfi@yahoo.it> writes:

> I confirm the bug.

Carsten has just fixed it while I was still writing. ;-)

> Org-mode version 7.4 commit-eb0d35dd185043933a0415222adc51906579dc67

hey, Giovanni, how can you use a 7 minutes old version?! :-)

Giovanni

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

* Re: Latex: exporting a tree
  2010-12-15 11:41     ` Carsten Dominik
@ 2010-12-15 12:13       ` Nicolas Goaziou
  2010-12-15 13:48         ` Carsten Dominik
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2010-12-15 12:13 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org Mode

Hello,

>>>>> Carsten Dominik writes:

> Nicolas, I believe this was one of your patches - the limited
> outline regexp needs to be anchored in the way you use it in
> org-latex.el.

Ok. Today, I will check others limited outline regexp in use.

Regards,

-- Nicolas

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

* Re: Latex: exporting a tree
  2010-12-15 12:13       ` Nicolas Goaziou
@ 2010-12-15 13:48         ` Carsten Dominik
  2010-12-15 18:15           ` Nicolas Goaziou
  0 siblings, 1 reply; 12+ messages in thread
From: Carsten Dominik @ 2010-12-15 13:48 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode


On Dec 15, 2010, at 1:13 PM, Nicolas Goaziou wrote:

> Hello,
>
>>>>>> Carsten Dominik writes:
>
>> Nicolas, I believe this was one of your patches - the limited
>> outline regexp needs to be anchored in the way you use it in
>> org-latex.el.
>
> Ok. Today, I will check others limited outline regexp in use.

Yes, thank you.   It is a bit confusing that outline-regexp itself is  
not anchored,
so all places who use it to search for a headline need the anchor  
added at re-search-forward time.  I think this is some history issue,  
and it may have to do with the fact that in the old days, outline  
forling was done by converting \n to \r and back, which makes and  
anchored regexp no longer match after \r ....

I fell over this issue *a lot* a couple of years ago :)

- Carsten

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

* Re: Latex: exporting a tree
  2010-12-15 13:48         ` Carsten Dominik
@ 2010-12-15 18:15           ` Nicolas Goaziou
  2010-12-15 22:12             ` Carsten Dominik
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2010-12-15 18:15 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org Mode

Hello,

Others uses of org-get-limited-outline-regexp are corrects.

Though, shouldn't I replace all those calls to
`org-get-limited-outline-regexp' with `org-with-limited-levels' macro?

Regards,

-- Nicolas

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

* Re: Latex: exporting a tree
  2010-12-15 18:15           ` Nicolas Goaziou
@ 2010-12-15 22:12             ` Carsten Dominik
  2010-12-19  0:15               ` Nicolas Goaziou
  0 siblings, 1 reply; 12+ messages in thread
From: Carsten Dominik @ 2010-12-15 22:12 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode


On Dec 15, 2010, at 7:15 PM, Nicolas Goaziou wrote:

> Hello,
>
> Others uses of org-get-limited-outline-regexp are corrects.
>
> Though, shouldn't I replace all those calls to
> `org-get-limited-outline-regexp' with `org-with-limited-levels' macro?

I have not looked closely at your new code - but yes, this is
what the macro is for!

Cheers

- Carsten

>
> Regards,
>
> -- Nicolas

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

* Re: Latex: exporting a tree
  2010-12-15 22:12             ` Carsten Dominik
@ 2010-12-19  0:15               ` Nicolas Goaziou
  2011-01-26 10:07                 ` [Accepted] " Carsten Dominik
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2010-12-19  0:15 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org Mode

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

Hello,

>>>>> Carsten Dominik writes:

>> Though, shouldn't I replace all those calls to
>> `org-get-limited-outline-regexp' with `org-with-limited-levels'
>> macro?

> I have not looked closely at your new code - but yes, this is what
> the macro is for!

The following patch does that, 3 times. I replaced one condition-case
with ignore-errors in the process.

As `org-store-link' is also modified, I did not apply it myself.

Regards,

-- Nicolas


[-- Attachment #2: 0001-Small-refactoring-with-org-with-limited-levels-macro.patch --]
[-- Type: text/plain, Size: 14787 bytes --]

From 2764d0a0fadec4fd6a2b3eab0ff98ca2e77d32d5 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Sun, 19 Dec 2010 00:39:13 +0100
Subject: [PATCH] Small refactoring with org-with-limited-levels macro

---
 lisp/org.el |  365 +++++++++++++++++++++++++++++------------------------------
 1 files changed, 181 insertions(+), 184 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 53039e4..75fb221 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7022,12 +7022,10 @@ in the region."
   "Return the level of the current entry, or nil if before the first headline.
 The level is the number of stars at the beginning of the headline."
   (save-excursion
-    (let ((outline-regexp (org-get-limited-outline-regexp)))
-      (condition-case nil
-	  (progn
-	    (org-back-to-heading t)
-	    (funcall outline-level))
-	(error nil)))))
+    (org-with-limited-levels
+     (ignore-errors
+       (org-back-to-heading t)
+       (funcall outline-level)))))
 
 (defun org-get-previous-line-level ()
   "Return the outline depth of the last headline before the current line.
@@ -8275,183 +8273,183 @@ For file links, arg negates `org-context-in-file-links'."
   (interactive "P")
   (org-load-modules-maybe)
   (setq org-store-link-plist nil)  ; reset
-  (let ((outline-regexp (org-get-limited-outline-regexp))
-	link cpltxt desc description search txt custom-id agenda-link)
-    (cond
-
-     ((run-hook-with-args-until-success 'org-store-link-functions)
-      (setq link (plist-get org-store-link-plist :link)
-	    desc (or (plist-get org-store-link-plist :description) link)))
-
-     ((equal (buffer-name) "*Org Edit Src Example*")
-      (let (label gc)
-	(while (or (not label)
-		   (save-excursion
-		     (save-restriction
-		       (widen)
-		       (goto-char (point-min))
-		       (re-search-forward
-			(regexp-quote (format org-coderef-label-format label))
-			nil t))))
-	  (when label (message "Label exists already") (sit-for 2))
-	  (setq label (read-string "Code line label: " label)))
-	(end-of-line 1)
-	(setq link (format org-coderef-label-format label))
-	(setq gc (- 79 (length link)))
-	(if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
-	(insert link)
-	(setq link (concat "(" label ")") desc nil)))
-
-     ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
-      ;; We are in the agenda, link to referenced location
-      (let ((m (or (get-text-property (point) 'org-hd-marker)
-		   (get-text-property (point) 'org-marker))))
-	(when m
-	  (org-with-point-at m
-	    (setq agenda-link
-		  (if (interactive-p)
-		      (call-interactively 'org-store-link)
-		    (org-store-link nil)))))))
-
-     ((eq major-mode 'calendar-mode)
-      (let ((cd (calendar-cursor-to-date)))
-	(setq link
-	      (format-time-string
-	       (car org-time-stamp-formats)
-	       (apply 'encode-time
-		      (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
-			    nil nil nil))))
-	(org-store-link-props :type "calendar" :date cd)))
-
-     ((eq major-mode 'w3-mode)
-      (setq cpltxt (if (and (buffer-name)
-			    (not (string-match "Untitled" (buffer-name))))
-		       (buffer-name)
-		     (url-view-url t))
-	    link (org-make-link (url-view-url t)))
-      (org-store-link-props :type "w3" :url (url-view-url t)))
-
-     ((eq major-mode 'w3m-mode)
-      (setq cpltxt (or w3m-current-title w3m-current-url)
-	    link (org-make-link w3m-current-url))
-      (org-store-link-props :type "w3m" :url (url-view-url t)))
-
-     ((setq search (run-hook-with-args-until-success
-		    'org-create-file-search-functions))
-      (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
-			 "::" search))
-      (setq cpltxt (or description link)))
-
-     ((eq major-mode 'image-mode)
-      (setq cpltxt (concat "file:"
-			   (abbreviate-file-name buffer-file-name))
-	    link (org-make-link cpltxt))
-      (org-store-link-props :type "image" :file buffer-file-name))
-
-     ((eq major-mode 'dired-mode)
-      ;; link to the file in the current line
-      (let ((file (dired-get-filename nil t)))
- 	(setq file (if file
- 		       (abbreviate-file-name
- 			(expand-file-name (dired-get-filename nil t)))
- 		     ;; otherwise, no file so use current directory.
- 		     default-directory))
- 	(setq cpltxt (concat "file:" file)
- 	      link (org-make-link cpltxt))))
-
-     ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
-      (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID")))
-      (cond
-       ((org-in-regexp "<<\\(.*?\\)>>")
-	(setq cpltxt
-	      (concat "file:"
-		      (abbreviate-file-name
-		       (buffer-file-name (buffer-base-buffer)))
-		      "::" (match-string 1))
-	      link (org-make-link cpltxt)))
-       ((and (featurep 'org-id)
-	     (or (eq org-link-to-org-use-id t)
-		 (and (eq org-link-to-org-use-id 'create-if-interactive)
-		      (interactive-p))
-		 (and (eq org-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
-		      (interactive-p)
-		      (not custom-id))
-		 (and org-link-to-org-use-id
-		      (condition-case nil
-			  (org-entry-get nil "ID")
-			(error nil)))))
-	;; We can make a link using the ID.
-	(setq link (condition-case nil
-		       (prog1 (org-id-store-link)
-			 (setq desc (plist-get org-store-link-plist
-					       :description)))
-		     (error
-		      ;; probably before first headline, link to file only
-		      (concat "file:"
+  (org-with-limited-levels
+   (let (link cpltxt desc description search txt custom-id agenda-link)
+     (cond
+
+      ((run-hook-with-args-until-success 'org-store-link-functions)
+       (setq link (plist-get org-store-link-plist :link)
+	     desc (or (plist-get org-store-link-plist :description) link)))
+
+      ((equal (buffer-name) "*Org Edit Src Example*")
+       (let (label gc)
+	 (while (or (not label)
+		    (save-excursion
+		      (save-restriction
+			(widen)
+			(goto-char (point-min))
+			(re-search-forward
+			 (regexp-quote (format org-coderef-label-format label))
+			 nil t))))
+	   (when label (message "Label exists already") (sit-for 2))
+	   (setq label (read-string "Code line label: " label)))
+	 (end-of-line 1)
+	 (setq link (format org-coderef-label-format label))
+	 (setq gc (- 79 (length link)))
+	 (if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
+	 (insert link)
+	 (setq link (concat "(" label ")") desc nil)))
+
+      ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
+       ;; We are in the agenda, link to referenced location
+       (let ((m (or (get-text-property (point) 'org-hd-marker)
+		    (get-text-property (point) 'org-marker))))
+	 (when m
+	   (org-with-point-at m
+	     (setq agenda-link
+		   (if (interactive-p)
+		       (call-interactively 'org-store-link)
+		     (org-store-link nil)))))))
+
+      ((eq major-mode 'calendar-mode)
+       (let ((cd (calendar-cursor-to-date)))
+	 (setq link
+	       (format-time-string
+		(car org-time-stamp-formats)
+		(apply 'encode-time
+		       (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
+			     nil nil nil))))
+	 (org-store-link-props :type "calendar" :date cd)))
+
+      ((eq major-mode 'w3-mode)
+       (setq cpltxt (if (and (buffer-name)
+			     (not (string-match "Untitled" (buffer-name))))
+			(buffer-name)
+		      (url-view-url t))
+	     link (org-make-link (url-view-url t)))
+       (org-store-link-props :type "w3" :url (url-view-url t)))
+
+      ((eq major-mode 'w3m-mode)
+       (setq cpltxt (or w3m-current-title w3m-current-url)
+	     link (org-make-link w3m-current-url))
+       (org-store-link-props :type "w3m" :url (url-view-url t)))
+
+      ((setq search (run-hook-with-args-until-success
+		     'org-create-file-search-functions))
+       (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
+			  "::" search))
+       (setq cpltxt (or description link)))
+
+      ((eq major-mode 'image-mode)
+       (setq cpltxt (concat "file:"
+			    (abbreviate-file-name buffer-file-name))
+	     link (org-make-link cpltxt))
+       (org-store-link-props :type "image" :file buffer-file-name))
+
+      ((eq major-mode 'dired-mode)
+       ;; link to the file in the current line
+       (let ((file (dired-get-filename nil t)))
+	 (setq file (if file
+			(abbreviate-file-name
+			 (expand-file-name (dired-get-filename nil t)))
+		      ;; otherwise, no file so use current directory.
+		      default-directory))
+	 (setq cpltxt (concat "file:" file)
+	       link (org-make-link cpltxt))))
+
+      ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
+       (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID")))
+       (cond
+	((org-in-regexp "<<\\(.*?\\)>>")
+	 (setq cpltxt
+	       (concat "file:"
+		       (abbreviate-file-name
+			(buffer-file-name (buffer-base-buffer)))
+		       "::" (match-string 1))
+	       link (org-make-link cpltxt)))
+	((and (featurep 'org-id)
+	      (or (eq org-link-to-org-use-id t)
+		  (and (eq org-link-to-org-use-id 'create-if-interactive)
+		       (interactive-p))
+		  (and (eq org-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
+		       (interactive-p)
+		       (not custom-id))
+		  (and org-link-to-org-use-id
+		       (condition-case nil
+			   (org-entry-get nil "ID")
+			 (error nil)))))
+	 ;; We can make a link using the ID.
+	 (setq link (condition-case nil
+			(prog1 (org-id-store-link)
+			  (setq desc (plist-get org-store-link-plist
+						:description)))
+		      (error
+		       ;; probably before first headline, link to file only
+		       (concat "file:"
+			       (abbreviate-file-name
+				(buffer-file-name (buffer-base-buffer))))))))
+	(t
+	 ;; Just link to current headline
+	 (setq cpltxt (concat "file:"
 			      (abbreviate-file-name
-			       (buffer-file-name (buffer-base-buffer))))))))
-       (t
-	;; Just link to current headline
-	(setq cpltxt (concat "file:"
-			     (abbreviate-file-name
-			      (buffer-file-name (buffer-base-buffer)))))
-	;; Add a context search string
-	(when (org-xor org-context-in-file-links arg)
-	  (setq txt (cond
-		     ((org-on-heading-p) nil)
-		     ((org-region-active-p)
-		      (buffer-substring (region-beginning) (region-end)))
-		     (t nil)))
-	  (when (or (null txt) (string-match "\\S-" txt))
-	    (setq cpltxt
-		  (concat cpltxt "::"
-			  (condition-case nil
-			      (org-make-org-heading-search-string txt)
-			    (error "")))
-		  desc (or (nth 4 (ignore-errors
-				    (org-heading-components))) "NONE"))))
-	(if (string-match "::\\'" cpltxt)
-	    (setq cpltxt (substring cpltxt 0 -2)))
-	(setq link (org-make-link cpltxt)))))
-
-     ((buffer-file-name (buffer-base-buffer))
-      ;; Just link to this file here.
-      (setq cpltxt (concat "file:"
-			   (abbreviate-file-name
-			    (buffer-file-name (buffer-base-buffer)))))
-      ;; Add a context string
-      (when (org-xor org-context-in-file-links arg)
-	(setq txt (if (org-region-active-p)
-		      (buffer-substring (region-beginning) (region-end))
-		    (buffer-substring (point-at-bol) (point-at-eol))))
-	;; Only use search option if there is some text.
-	(when (string-match "\\S-" txt)
-	  (setq cpltxt
-		(concat cpltxt "::" (org-make-org-heading-search-string txt))
-		desc "NONE")))
-      (setq link (org-make-link cpltxt)))
-
-     ((interactive-p)
-      (error "Cannot link to a buffer which is not visiting a file"))
-
-     (t (setq link nil)))
-
-    (if (consp link) (setq cpltxt (car link) link (cdr link)))
-    (setq link (or link cpltxt)
-	  desc (or desc cpltxt))
-    (if (equal desc "NONE") (setq desc nil))
-
-    (if (and (or (interactive-p) executing-kbd-macro) link)
-	(progn
-	  (setq org-stored-links
-		(cons (list link desc) org-stored-links))
-	  (message "Stored: %s" (or desc link))
-	  (when custom-id
-	    (setq link (concat "file:" (abbreviate-file-name (buffer-file-name))
-			       "::#" custom-id))
-	    (setq org-stored-links
-		  (cons (list link desc) org-stored-links))))
-      (or agenda-link (and link (org-make-link-string link desc))))))
+			       (buffer-file-name (buffer-base-buffer)))))
+	 ;; Add a context search string
+	 (when (org-xor org-context-in-file-links arg)
+	   (setq txt (cond
+		      ((org-on-heading-p) nil)
+		      ((org-region-active-p)
+		       (buffer-substring (region-beginning) (region-end)))
+		      (t nil)))
+	   (when (or (null txt) (string-match "\\S-" txt))
+	     (setq cpltxt
+		   (concat cpltxt "::"
+			   (condition-case nil
+			       (org-make-org-heading-search-string txt)
+			     (error "")))
+		   desc (or (nth 4 (ignore-errors
+				     (org-heading-components))) "NONE"))))
+	 (if (string-match "::\\'" cpltxt)
+	     (setq cpltxt (substring cpltxt 0 -2)))
+	 (setq link (org-make-link cpltxt)))))
+
+      ((buffer-file-name (buffer-base-buffer))
+       ;; Just link to this file here.
+       (setq cpltxt (concat "file:"
+			    (abbreviate-file-name
+			     (buffer-file-name (buffer-base-buffer)))))
+       ;; Add a context string
+       (when (org-xor org-context-in-file-links arg)
+	 (setq txt (if (org-region-active-p)
+		       (buffer-substring (region-beginning) (region-end))
+		     (buffer-substring (point-at-bol) (point-at-eol))))
+	 ;; Only use search option if there is some text.
+	 (when (string-match "\\S-" txt)
+	   (setq cpltxt
+		 (concat cpltxt "::" (org-make-org-heading-search-string txt))
+		 desc "NONE")))
+       (setq link (org-make-link cpltxt)))
+
+      ((interactive-p)
+       (error "Cannot link to a buffer which is not visiting a file"))
+
+      (t (setq link nil)))
+
+     (if (consp link) (setq cpltxt (car link) link (cdr link)))
+     (setq link (or link cpltxt)
+	   desc (or desc cpltxt))
+     (if (equal desc "NONE") (setq desc nil))
+
+     (if (and (or (interactive-p) executing-kbd-macro) link)
+	 (progn
+	   (setq org-stored-links
+		 (cons (list link desc) org-stored-links))
+	   (message "Stored: %s" (or desc link))
+	   (when custom-id
+	     (setq link (concat "file:" (abbreviate-file-name (buffer-file-name))
+				"::#" custom-id))
+	     (setq org-stored-links
+		   (cons (list link desc) org-stored-links))))
+       (or agenda-link (and link (org-make-link-string link desc)))))))
 
 (defun org-store-link-props (&rest plist)
   "Store link properties, extract names and addresses."
@@ -18605,8 +18603,7 @@ If point is in an inline task, mark that task instead."
     (cond
      (inline-task-p (org-inlinetask-goto-beginning))
      ((org-at-heading-p) (beginning-of-line))
-     (t (let ((outline-regexp (org-get-limited-outline-regexp)))
-	  (outline-previous-visible-heading 1))))
+     (t (org-with-limited-levels (outline-previous-visible-heading 1))))
     (setq beg (point))
     ;; Get end of it
     (if	inline-task-p
-- 
1.7.3.3


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

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* [Accepted] Latex: exporting a tree
  2010-12-19  0:15               ` Nicolas Goaziou
@ 2011-01-26 10:07                 ` Carsten Dominik
  0 siblings, 0 replies; 12+ messages in thread
From: Carsten Dominik @ 2011-01-26 10:07 UTC (permalink / raw)
  To: emacs-orgmode

Patch 493 (http://patchwork.newartisans.com/patch/493/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C87sjxuty6w.wl%25n.goaziou%40gmail.com%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] Latex: exporting a tree
> Date: Sun, 19 Dec 2010 05:15:35 -0000
> From: Nicolas Goaziou <n.goaziou@gmail.com>
> X-Patchwork-Id: 493
> Message-Id: <87sjxuty6w.wl%n.goaziou@gmail.com>
> To: Carsten Dominik <carsten.dominik@gmail.com>
> Cc: Org Mode <emacs-orgmode@gnu.org>
> 
> Hello,
> 
> >>>>> Carsten Dominik writes:
> 
> >> Though, shouldn't I replace all those calls to
> >> `org-get-limited-outline-regexp' with `org-with-limited-levels'
> >> macro?
> 
> > I have not looked closely at your new code - but yes, this is what
> > the macro is for!
> 
> The following patch does that, 3 times. I replaced one condition-case
> with ignore-errors in the process.
> 
> As `org-store-link' is also modified, I did not apply it myself.
> 
> Regards,
> 
> -- Nicolas
> >From 2764d0a0fadec4fd6a2b3eab0ff98ca2e77d32d5 Mon Sep 17 00:00:00 2001
> From: Nicolas Goaziou <n.goaziou@gmail.com>
> Date: Sun, 19 Dec 2010 00:39:13 +0100
> Subject: [PATCH] Small refactoring with org-with-limited-levels macro
> 
> ---
> lisp/org.el |  365 +++++++++++++++++++++++++++++------------------------------
>  1 files changed, 181 insertions(+), 184 deletions(-)
> 
> diff --git a/lisp/org.el b/lisp/org.el
> index 53039e4..75fb221 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -7022,12 +7022,10 @@ in the region."
>    "Return the level of the current entry, or nil if before the first headline.
>  The level is the number of stars at the beginning of the headline."
>    (save-excursion
> -    (let ((outline-regexp (org-get-limited-outline-regexp)))
> -      (condition-case nil
> -	  (progn
> -	    (org-back-to-heading t)
> -	    (funcall outline-level))
> -	(error nil)))))
> +    (org-with-limited-levels
> +     (ignore-errors
> +       (org-back-to-heading t)
> +       (funcall outline-level)))))
>  
>  (defun org-get-previous-line-level ()
>    "Return the outline depth of the last headline before the current line.
> @@ -8275,183 +8273,183 @@ For file links, arg negates `org-context-in-file-links'."
>    (interactive "P")
>    (org-load-modules-maybe)
>    (setq org-store-link-plist nil)  ; reset
> -  (let ((outline-regexp (org-get-limited-outline-regexp))
> -	link cpltxt desc description search txt custom-id agenda-link)
> -    (cond
> -
> -     ((run-hook-with-args-until-success 'org-store-link-functions)
> -      (setq link (plist-get org-store-link-plist :link)
> -	    desc (or (plist-get org-store-link-plist :description) link)))
> -
> -     ((equal (buffer-name) "*Org Edit Src Example*")
> -      (let (label gc)
> -	(while (or (not label)
> -		   (save-excursion
> -		     (save-restriction
> -		       (widen)
> -		       (goto-char (point-min))
> -		       (re-search-forward
> -			(regexp-quote (format org-coderef-label-format label))
> -			nil t))))
> -	  (when label (message "Label exists already") (sit-for 2))
> -	  (setq label (read-string "Code line label: " label)))
> -	(end-of-line 1)
> -	(setq link (format org-coderef-label-format label))
> -	(setq gc (- 79 (length link)))
> -	(if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
> -	(insert link)
> -	(setq link (concat "(" label ")") desc nil)))
> -
> -     ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
> -      ;; We are in the agenda, link to referenced location
> -      (let ((m (or (get-text-property (point) 'org-hd-marker)
> -		   (get-text-property (point) 'org-marker))))
> -	(when m
> -	  (org-with-point-at m
> -	    (setq agenda-link
> -		  (if (interactive-p)
> -		      (call-interactively 'org-store-link)
> -		    (org-store-link nil)))))))
> -
> -     ((eq major-mode 'calendar-mode)
> -      (let ((cd (calendar-cursor-to-date)))
> -	(setq link
> -	      (format-time-string
> -	       (car org-time-stamp-formats)
> -	       (apply 'encode-time
> -		      (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
> -			    nil nil nil))))
> -	(org-store-link-props :type "calendar" :date cd)))
> -
> -     ((eq major-mode 'w3-mode)
> -      (setq cpltxt (if (and (buffer-name)
> -			    (not (string-match "Untitled" (buffer-name))))
> -		       (buffer-name)
> -		     (url-view-url t))
> -	    link (org-make-link (url-view-url t)))
> -      (org-store-link-props :type "w3" :url (url-view-url t)))
> -
> -     ((eq major-mode 'w3m-mode)
> -      (setq cpltxt (or w3m-current-title w3m-current-url)
> -	    link (org-make-link w3m-current-url))
> -      (org-store-link-props :type "w3m" :url (url-view-url t)))
> -
> -     ((setq search (run-hook-with-args-until-success
> -		    'org-create-file-search-functions))
> -      (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
> -			 "::" search))
> -      (setq cpltxt (or description link)))
> -
> -     ((eq major-mode 'image-mode)
> -      (setq cpltxt (concat "file:"
> -			   (abbreviate-file-name buffer-file-name))
> -	    link (org-make-link cpltxt))
> -      (org-store-link-props :type "image" :file buffer-file-name))
> -
> -     ((eq major-mode 'dired-mode)
> -      ;; link to the file in the current line
> -      (let ((file (dired-get-filename nil t)))
> - 	(setq file (if file
> - 		       (abbreviate-file-name
> - 			(expand-file-name (dired-get-filename nil t)))
> - 		     ;; otherwise, no file so use current directory.
> - 		     default-directory))
> - 	(setq cpltxt (concat "file:" file)
> - 	      link (org-make-link cpltxt))))
> -
> -     ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
> -      (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID")))
> -      (cond
> -       ((org-in-regexp "<<\\(.*?\\)>>")
> -	(setq cpltxt
> -	      (concat "file:"
> -		      (abbreviate-file-name
> -		       (buffer-file-name (buffer-base-buffer)))
> -		      "::" (match-string 1))
> -	      link (org-make-link cpltxt)))
> -       ((and (featurep 'org-id)
> -	     (or (eq org-link-to-org-use-id t)
> -		 (and (eq org-link-to-org-use-id 'create-if-interactive)
> -		      (interactive-p))
> -		 (and (eq org-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
> -		      (interactive-p)
> -		      (not custom-id))
> -		 (and org-link-to-org-use-id
> -		      (condition-case nil
> -			  (org-entry-get nil "ID")
> -			(error nil)))))
> -	;; We can make a link using the ID.
> -	(setq link (condition-case nil
> -		       (prog1 (org-id-store-link)
> -			 (setq desc (plist-get org-store-link-plist
> -					       :description)))
> -		     (error
> -		      ;; probably before first headline, link to file only
> -		      (concat "file:"
> +  (org-with-limited-levels
> +   (let (link cpltxt desc description search txt custom-id agenda-link)
> +     (cond
> +
> +      ((run-hook-with-args-until-success 'org-store-link-functions)
> +       (setq link (plist-get org-store-link-plist :link)
> +	     desc (or (plist-get org-store-link-plist :description) link)))
> +
> +      ((equal (buffer-name) "*Org Edit Src Example*")
> +       (let (label gc)
> +	 (while (or (not label)
> +		    (save-excursion
> +		      (save-restriction
> +			(widen)
> +			(goto-char (point-min))
> +			(re-search-forward
> +			 (regexp-quote (format org-coderef-label-format label))
> +			 nil t))))
> +	   (when label (message "Label exists already") (sit-for 2))
> +	   (setq label (read-string "Code line label: " label)))
> +	 (end-of-line 1)
> +	 (setq link (format org-coderef-label-format label))
> +	 (setq gc (- 79 (length link)))
> +	 (if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
> +	 (insert link)
> +	 (setq link (concat "(" label ")") desc nil)))
> +
> +      ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
> +       ;; We are in the agenda, link to referenced location
> +       (let ((m (or (get-text-property (point) 'org-hd-marker)
> +		    (get-text-property (point) 'org-marker))))
> +	 (when m
> +	   (org-with-point-at m
> +	     (setq agenda-link
> +		   (if (interactive-p)
> +		       (call-interactively 'org-store-link)
> +		     (org-store-link nil)))))))
> +
> +      ((eq major-mode 'calendar-mode)
> +       (let ((cd (calendar-cursor-to-date)))
> +	 (setq link
> +	       (format-time-string
> +		(car org-time-stamp-formats)
> +		(apply 'encode-time
> +		       (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
> +			     nil nil nil))))
> +	 (org-store-link-props :type "calendar" :date cd)))
> +
> +      ((eq major-mode 'w3-mode)
> +       (setq cpltxt (if (and (buffer-name)
> +			     (not (string-match "Untitled" (buffer-name))))
> +			(buffer-name)
> +		      (url-view-url t))
> +	     link (org-make-link (url-view-url t)))
> +       (org-store-link-props :type "w3" :url (url-view-url t)))
> +
> +      ((eq major-mode 'w3m-mode)
> +       (setq cpltxt (or w3m-current-title w3m-current-url)
> +	     link (org-make-link w3m-current-url))
> +       (org-store-link-props :type "w3m" :url (url-view-url t)))
> +
> +      ((setq search (run-hook-with-args-until-success
> +		     'org-create-file-search-functions))
> +       (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
> +			  "::" search))
> +       (setq cpltxt (or description link)))
> +
> +      ((eq major-mode 'image-mode)
> +       (setq cpltxt (concat "file:"
> +			    (abbreviate-file-name buffer-file-name))
> +	     link (org-make-link cpltxt))
> +       (org-store-link-props :type "image" :file buffer-file-name))
> +
> +      ((eq major-mode 'dired-mode)
> +       ;; link to the file in the current line
> +       (let ((file (dired-get-filename nil t)))
> +	 (setq file (if file
> +			(abbreviate-file-name
> +			 (expand-file-name (dired-get-filename nil t)))
> +		      ;; otherwise, no file so use current directory.
> +		      default-directory))
> +	 (setq cpltxt (concat "file:" file)
> +	       link (org-make-link cpltxt))))
> +
> +      ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
> +       (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID")))
> +       (cond
> +	((org-in-regexp "<<\\(.*?\\)>>")
> +	 (setq cpltxt
> +	       (concat "file:"
> +		       (abbreviate-file-name
> +			(buffer-file-name (buffer-base-buffer)))
> +		       "::" (match-string 1))
> +	       link (org-make-link cpltxt)))
> +	((and (featurep 'org-id)
> +	      (or (eq org-link-to-org-use-id t)
> +		  (and (eq org-link-to-org-use-id 'create-if-interactive)
> +		       (interactive-p))
> +		  (and (eq org-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
> +		       (interactive-p)
> +		       (not custom-id))
> +		  (and org-link-to-org-use-id
> +		       (condition-case nil
> +			   (org-entry-get nil "ID")
> +			 (error nil)))))
> +	 ;; We can make a link using the ID.
> +	 (setq link (condition-case nil
> +			(prog1 (org-id-store-link)
> +			  (setq desc (plist-get org-store-link-plist
> +						:description)))
> +		      (error
> +		       ;; probably before first headline, link to file only
> +		       (concat "file:"
> +			       (abbreviate-file-name
> +				(buffer-file-name (buffer-base-buffer))))))))
> +	(t
> +	 ;; Just link to current headline
> +	 (setq cpltxt (concat "file:"
>  			      (abbreviate-file-name
> -			       (buffer-file-name (buffer-base-buffer))))))))
> -       (t
> -	;; Just link to current headline
> -	(setq cpltxt (concat "file:"
> -			     (abbreviate-file-name
> -			      (buffer-file-name (buffer-base-buffer)))))
> -	;; Add a context search string
> -	(when (org-xor org-context-in-file-links arg)
> -	  (setq txt (cond
> -		     ((org-on-heading-p) nil)
> -		     ((org-region-active-p)
> -		      (buffer-substring (region-beginning) (region-end)))
> -		     (t nil)))
> -	  (when (or (null txt) (string-match "\\S-" txt))
> -	    (setq cpltxt
> -		  (concat cpltxt "::"
> -			  (condition-case nil
> -			      (org-make-org-heading-search-string txt)
> -			    (error "")))
> -		  desc (or (nth 4 (ignore-errors
> -				    (org-heading-components))) "NONE"))))
> -	(if (string-match "::\\'" cpltxt)
> -	    (setq cpltxt (substring cpltxt 0 -2)))
> -	(setq link (org-make-link cpltxt)))))
> -
> -     ((buffer-file-name (buffer-base-buffer))
> -      ;; Just link to this file here.
> -      (setq cpltxt (concat "file:"
> -			   (abbreviate-file-name
> -			    (buffer-file-name (buffer-base-buffer)))))
> -      ;; Add a context string
> -      (when (org-xor org-context-in-file-links arg)
> -	(setq txt (if (org-region-active-p)
> -		      (buffer-substring (region-beginning) (region-end))
> -		    (buffer-substring (point-at-bol) (point-at-eol))))
> -	;; Only use search option if there is some text.
> -	(when (string-match "\\S-" txt)
> -	  (setq cpltxt
> -		(concat cpltxt "::" (org-make-org-heading-search-string txt))
> -		desc "NONE")))
> -      (setq link (org-make-link cpltxt)))
> -
> -     ((interactive-p)
> -      (error "Cannot link to a buffer which is not visiting a file"))
> -
> -     (t (setq link nil)))
> -
> -    (if (consp link) (setq cpltxt (car link) link (cdr link)))
> -    (setq link (or link cpltxt)
> -	  desc (or desc cpltxt))
> -    (if (equal desc "NONE") (setq desc nil))
> -
> -    (if (and (or (interactive-p) executing-kbd-macro) link)
> -	(progn
> -	  (setq org-stored-links
> -		(cons (list link desc) org-stored-links))
> -	  (message "Stored: %s" (or desc link))
> -	  (when custom-id
> -	    (setq link (concat "file:" (abbreviate-file-name (buffer-file-name))
> -			       "::#" custom-id))
> -	    (setq org-stored-links
> -		  (cons (list link desc) org-stored-links))))
> -      (or agenda-link (and link (org-make-link-string link desc))))))
> +			       (buffer-file-name (buffer-base-buffer)))))
> +	 ;; Add a context search string
> +	 (when (org-xor org-context-in-file-links arg)
> +	   (setq txt (cond
> +		      ((org-on-heading-p) nil)
> +		      ((org-region-active-p)
> +		       (buffer-substring (region-beginning) (region-end)))
> +		      (t nil)))
> +	   (when (or (null txt) (string-match "\\S-" txt))
> +	     (setq cpltxt
> +		   (concat cpltxt "::"
> +			   (condition-case nil
> +			       (org-make-org-heading-search-string txt)
> +			     (error "")))
> +		   desc (or (nth 4 (ignore-errors
> +				     (org-heading-components))) "NONE"))))
> +	 (if (string-match "::\\'" cpltxt)
> +	     (setq cpltxt (substring cpltxt 0 -2)))
> +	 (setq link (org-make-link cpltxt)))))
> +
> +      ((buffer-file-name (buffer-base-buffer))
> +       ;; Just link to this file here.
> +       (setq cpltxt (concat "file:"
> +			    (abbreviate-file-name
> +			     (buffer-file-name (buffer-base-buffer)))))
> +       ;; Add a context string
> +       (when (org-xor org-context-in-file-links arg)
> +	 (setq txt (if (org-region-active-p)
> +		       (buffer-substring (region-beginning) (region-end))
> +		     (buffer-substring (point-at-bol) (point-at-eol))))
> +	 ;; Only use search option if there is some text.
> +	 (when (string-match "\\S-" txt)
> +	   (setq cpltxt
> +		 (concat cpltxt "::" (org-make-org-heading-search-string txt))
> +		 desc "NONE")))
> +       (setq link (org-make-link cpltxt)))
> +
> +      ((interactive-p)
> +       (error "Cannot link to a buffer which is not visiting a file"))
> +
> +      (t (setq link nil)))
> +
> +     (if (consp link) (setq cpltxt (car link) link (cdr link)))
> +     (setq link (or link cpltxt)
> +	   desc (or desc cpltxt))
> +     (if (equal desc "NONE") (setq desc nil))
> +
> +     (if (and (or (interactive-p) executing-kbd-macro) link)
> +	 (progn
> +	   (setq org-stored-links
> +		 (cons (list link desc) org-stored-links))
> +	   (message "Stored: %s" (or desc link))
> +	   (when custom-id
> +	     (setq link (concat "file:" (abbreviate-file-name (buffer-file-name))
> +				"::#" custom-id))
> +	     (setq org-stored-links
> +		   (cons (list link desc) org-stored-links))))
> +       (or agenda-link (and link (org-make-link-string link desc)))))))
>  
>  (defun org-store-link-props (&rest plist)
>    "Store link properties, extract names and addresses."
> @@ -18605,8 +18603,7 @@ If point is in an inline task, mark that task instead."
>      (cond
>       (inline-task-p (org-inlinetask-goto-beginning))
>       ((org-at-heading-p) (beginning-of-line))
> -     (t (let ((outline-regexp (org-get-limited-outline-regexp)))
> -	  (outline-previous-visible-heading 1))))
> +     (t (org-with-limited-levels (outline-previous-visible-heading 1))))
>      (setq beg (point))
>      ;; Get end of it
>      (if	inline-task-p
> 

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

end of thread, other threads:[~2011-01-26 10:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-09  9:02 Latex: exporting a tree Jörg Hagmann
2010-12-10 14:49 ` Jörg Hagmann
2010-12-15 10:04   ` Jörg Hagmann
2010-12-15 11:41     ` Carsten Dominik
2010-12-15 12:13       ` Nicolas Goaziou
2010-12-15 13:48         ` Carsten Dominik
2010-12-15 18:15           ` Nicolas Goaziou
2010-12-15 22:12             ` Carsten Dominik
2010-12-19  0:15               ` Nicolas Goaziou
2011-01-26 10:07                 ` [Accepted] " Carsten Dominik
2010-12-15 11:45     ` BUG " Giovanni Ridolfi
2010-12-15 11:53       ` Giovanni Ridolfi

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