emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] lisp/ox-publish.el: Handle includes with searches
@ 2015-11-14 21:56 Nick Gunn
  2015-11-23 11:11 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Gunn @ 2015-11-14 21:56 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Nick Gunn

* lisp/ox-publish.el (org-publish-cache-file-needs-publishing): Ignore
  any link search suffix on an include so that the path represents a
  valid file during the publishing check.

TINYCHANGE
---
 lisp/ox-publish.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index c7da953..7799d8b 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -1244,8 +1244,8 @@ the file including them will be republished as well."
 		       (let ((value (org-element-property :value element)))
 			 (and value
 			      (string-match "^\\(\".+?\"\\|\\S-+\\)" value)
-			      (org-remove-double-quotes
-			       (match-string 1 value)))))))
+			      (car (split-string (org-remove-double-quotes
+						  (match-string 1 value)) "::")))))))
 	    (when included-file
 	      (push (org-publish-cache-ctime-of-src
 		     (expand-file-name included-file))
-- 
2.5.2

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

* Re: [PATCH] lisp/ox-publish.el: Handle includes with searches
  2015-11-14 21:56 [PATCH] lisp/ox-publish.el: Handle includes with searches Nick Gunn
@ 2015-11-23 11:11 ` Nicolas Goaziou
  2015-12-29  1:35   ` aman
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2015-11-23 11:11 UTC (permalink / raw)
  To: Nick Gunn; +Cc: emacs-orgmode

Hello,

Nick Gunn <nick@ausimian.net> writes:

> * lisp/ox-publish.el (org-publish-cache-file-needs-publishing): Ignore
>   any link search suffix on an include so that the path represents a
>   valid file during the publishing check.

Applied. Thank you.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] lisp/ox-publish.el: Handle includes with searches
  2015-11-23 11:11 ` Nicolas Goaziou
@ 2015-12-29  1:35   ` aman
  2015-12-29 21:17     ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: aman @ 2015-12-29  1:35 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail <at> nicolasgoaziou.fr> writes:

> 
> Hello,
> 
> Nick Gunn <nick <at> ausimian.net> writes:
> 
> > * lisp/ox-publish.el (org-publish-cache-file-needs-publishing): Ignore
> >   any link search suffix on an include so that the path represents a
> >   valid file during the publishing check.
> 
> Applied. Thank you.
> 
> Regards,
> 


Hi,
    I was using org-publish which was already applied with this patch.
    but I got following error message when I published an org file including
another one.
    <error message>
    org-publish-cache-ctime-of-src: No such file:
"/home/emacs/gtd/inbox.org::writing"
    </error>
    
   here's the including block:
   <block>
   * including file
      #+INCLUDE: "../../inbox.org::writing blog" :only-contents t
   </block>

    This patch works fine if there's spaces between "inbox.org" and
"::writing blog".

    And I found that org-export-expand-include-keyword, invoked by`C-c '` at
INCLUDE statement, awalys get right file name.

    I copied some logic from org-export-expand-include-keyword to make it
works for me. 

--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -1243,13 +1243,17 @@ the file including them will be republished as well."
 		  (and (eq (org-element-type element) 'keyword)
 		       (let ((value (org-element-property :value element)))
 			 (and value
-			      (string-match "^\\(\".+?\"\\|\\S-+\\)" value)
-			      ;; Ignore search suffix.
-			      (car (split-string
-				    (org-remove-double-quotes
-				     (match-string 1 value)))))))))
+			      (string-match "^\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)" value)
+                              (let ((matched (match-string 1 value)))
+                                (when (string-match "\\(::\\(.*?\\)\\)\"?\\'"
+						   matched)
+                                  (setq matched
+                                        (replace-match "" nil nil matched 1))
+                                  (print matched))
+                                (org-remove-double-quotes matched))
+                              )))))
 	    (when included-file
-	      (push (org-publish-cache-ctime-of-src
+	      (push (org-publish-cache-ctime-oef-src
 		     (expand-file-name included-file))
 		    included-files-ctime)))))
       (unless visiting (kill-buffer buf)))

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

* Re: [PATCH] lisp/ox-publish.el: Handle includes with searches
  2015-12-29  1:35   ` aman
@ 2015-12-29 21:17     ` Nicolas Goaziou
  2015-12-30  6:44       ` aman
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2015-12-29 21:17 UTC (permalink / raw)
  To: aman; +Cc: emacs-orgmode

Hello,

aman <aman_yang@163.com> writes:

>     I was using org-publish which was already applied with this patch.
>     but I got following error message when I published an org file including
> another one.
>     <error message>
>     org-publish-cache-ctime-of-src: No such file:
> "/home/emacs/gtd/inbox.org::writing"
>     </error>
>     
>    here's the including block:
>    <block>
>    * including file
>       #+INCLUDE: "../../inbox.org::writing blog" :only-contents t
>    </block>
>
>     This patch works fine if there's spaces between "inbox.org" and
> "::writing blog".

Indeed.

> -			      (string-match "^\\(\".+?\"\\|\\S-+\\)" value)
> -			      ;; Ignore search suffix.
> -			      (car (split-string
> -				    (org-remove-double-quotes
> -				     (match-string 1 value)))))))))
> +			      (string-match "^\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)" value)
> +                              (let ((matched (match-string 1 value)))
> +                                (when (string-match "\\(::\\(.*?\\)\\)\"?\\'"
> +						   matched)
> +                                  (setq matched
> +                                        (replace-match "" nil nil matched 1))
> +                                  (print matched))
> +                                (org-remove-double-quotes matched))
> +                              )))))

You should remove (print matched). Also, parenthesis should not be alone
on their own line.

I suggest to replace it with:

  (let ((matched (match-string 1 value)))
    (org-remove-double-quotes
     (if (string-match "\\(::\\(.*?\\)\\)\"?\\'" matched)
         (substring matched 0 (match-beginning 0))
       matched)))

>  	    (when included-file
> -	      (push (org-publish-cache-ctime-of-src
> +	      (push (org-publish-cache-ctime-oef-src

Typo.


Eventually, could you provide an appropriate commit message?

Thank you.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] lisp/ox-publish.el: Handle includes with searches
  2015-12-29 21:17     ` Nicolas Goaziou
@ 2015-12-30  6:44       ` aman
  2015-12-30  9:20         ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: aman @ 2015-12-30  6:44 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Nicolas Goaziou <mail <at> nicolasgoaziou.fr> writes:
> 
> Hello,
> 
> aman <aman_yang <at> 163.com> writes:
> 
> >     I was using org-publish which was already applied with this patch.
> >     but I got following error message when I published an org file including
> > another one.
> >     <error message>
> >     org-publish-cache-ctime-of-src: No such file:
> > "/home/emacs/gtd/inbox.org::writing"
> >     </error>
> >     
> >    here's the including block:
> >    <block>
> >    * including file
> >       #+INCLUDE: "../../inbox.org::writing blog" :only-contents t
> >    </block>
> >
> >     This patch works fine if there's spaces between "inbox.org" and
> > "::writing blog".
> 
> Indeed.
> 
> > -			      (string-match "^\\(\".+?\"\\|\\S-+\\)" value)
> > -			      ;; Ignore search suffix.
> > -			      (car (split-string
> > -				    (org-remove-double-quotes
> > -				     (match-string 1 value)))))))))
> > +			      (string-match "^\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)" value)
> > +                              (let ((matched (match-string 1 value)))
> > +                                (when (string-match
"\\(::\\(.*?\\)\\)\"?\\'"
> > +						   matched)
> > +                                  (setq matched
> > +                                        (replace-match "" nil nil
matched 1))
> > +                                  (print matched))
> > +                                (org-remove-double-quotes matched))
> > +                              )))))
> 
> You should remove (print matched). Also, parenthesis should not be alone
> on their own line.
> 
> I suggest to replace it with:
> 
>   (let ((matched (match-string 1 value)))
>     (org-remove-double-quotes
>      (if (string-match "\\(::\\(.*?\\)\\)\"?\\'" matched)
>          (substring matched 0 (match-beginning 0))
>        matched)))
Got it, that's more succinct. 

> 
> >  	    (when included-file
> > -	      (push (org-publish-cache-ctime-of-src
> > +	      (push (org-publish-cache-ctime-oef-src
> 
> Typo.
> 
> Eventually, could you provide an appropriate commit message?
> 
> Thank you.
> 
> Regards,
> 

Here's new patch, and hope it helps.

org-publish: Fix get 'included-file' logic.

* lisp/ox-publish.el (org-publish-cache-file-needs-publishing):
  According to the syntax of #+INCLUDE statement in *info* page,
  there's no space between search option and file path.
  Fix it.

diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index b49b9d3..9cfa596 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -1243,11 +1243,12 @@ the file including them will be republished as well."
           (and (eq (org-element-type element) 'keyword)
                (let ((value (org-element-property :value element)))
              (and value
-                  (string-match "^\\(\".+?\"\\|\\S-+\\)" value)
-                  ;; Ignore search suffix.
-                  (car (split-string
-                    (org-remove-double-quotes
-                     (match-string 1 value)))))))))
+                  (string-match "^\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)"
value)
+                    (let ((matched (match-string 1 value)))
+                  (org-remove-double-quotes
+                   (if (string-match "\\(::\\(.*?\\)\\)\"?\\'" matched)
+                       (substring matched 0 (match-beginning 0))
+                     matched))))))))
         (when included-file
           (push (org-publish-cache-ctime-of-src
              (expand-file-name included-file))
-- 
1.9.1


Thank You.

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

* Re: [PATCH] lisp/ox-publish.el: Handle includes with searches
  2015-12-30  6:44       ` aman
@ 2015-12-30  9:20         ` Nicolas Goaziou
  2015-12-30 11:28           ` aman
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2015-12-30  9:20 UTC (permalink / raw)
  To: aman; +Cc: emacs-orgmode

Hello,

aman <aman_yang@163.com> writes:

> Here's new patch, and hope it helps.
>
> org-publish: Fix get 'included-file' logic.
>
> * lisp/ox-publish.el (org-publish-cache-file-needs-publishing):
>   According to the syntax of #+INCLUDE statement in *info* page,
>   there's no space between search option and file path.
>   Fix it.

Thank you. It looks good.

Have you signed FSF papers already? Otherwise, you need to add
TINYCHANGE at the end of the commit message.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] lisp/ox-publish.el: Handle includes with searches
  2015-12-30  9:20         ` Nicolas Goaziou
@ 2015-12-30 11:28           ` aman
  2015-12-30 23:35             ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: aman @ 2015-12-30 11:28 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail <at> nicolasgoaziou.fr> writes:

> 
> Hello,
> 
> aman <aman_yang <at> 163.com> writes:
> 
> > Here's new patch, and hope it helps.
> >
> > org-publish: Fix get 'included-file' logic.
> >
> > * lisp/ox-publish.el (org-publish-cache-file-needs-publishing):
> >   According to the syntax of #+INCLUDE statement in *info* page,
> >   there's no space between search option and file path.
> >   Fix it.
> 
> Thank you. It looks good.
> 
> Have you signed FSF papers already? Otherwise, you need to add
> TINYCHANGE at the end of the commit message.
> 
> Regards,
> 

Oh Sorry. I didn't read contribution guide careful.
This is my first patch to GNU.

Is these words OK?

 org-publish: Fix get `included-file' logic.

 * lisp/ox-publish.el (org-publish-cache-file-needs-publishing):
   According to the syntax of #+INCLUDE statement in *info* page,
   there's no space between search option and file path.
   Make a TINYCHANGE to fix it.

Best Regards

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

* Re: [PATCH] lisp/ox-publish.el: Handle includes with searches
  2015-12-30 11:28           ` aman
@ 2015-12-30 23:35             ` Nicolas Goaziou
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2015-12-30 23:35 UTC (permalink / raw)
  To: aman; +Cc: emacs-orgmode

Hello,

aman <aman_yang@163.com> writes:

>  org-publish: Fix get `included-file' logic.
>
>  * lisp/ox-publish.el (org-publish-cache-file-needs-publishing):
>    According to the syntax of #+INCLUDE statement in *info* page,
>    there's no space between search option and file path.
>    Make a TINYCHANGE to fix it.

Actually, TINYCHANGE is expected to be on its own on a separate line.
This is a minor issue, tho.

I pushed your patch along with the new commit message in maint brach.

Thank you.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2015-12-30 23:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-14 21:56 [PATCH] lisp/ox-publish.el: Handle includes with searches Nick Gunn
2015-11-23 11:11 ` Nicolas Goaziou
2015-12-29  1:35   ` aman
2015-12-29 21:17     ` Nicolas Goaziou
2015-12-30  6:44       ` aman
2015-12-30  9:20         ` Nicolas Goaziou
2015-12-30 11:28           ` aman
2015-12-30 23:35             ` Nicolas Goaziou

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