emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] Fix and optimize publishing cache check


From: Nicolas Goaziou
Subject: Re: [O] [PATCH] Fix and optimize publishing cache check
Date: Thu, 14 Aug 2014 11:13:32 +0200

Hello,

Matt Lundin <address@hidden> writes:

> Here is an improved version of the previous patch (please apply it
> rather than the previous).

Thank you for the patch.

> This version further optimizes cache checking by only calling
> find-buffer-visiting if necessary. (It also fixes some long lines.) On
> a test project containing 5000 files, running org-publish on the
> project with the cache enabled now takes seconds rather than minutes.

Great.

> +      (ctime (org-publish-cache-ctime-of-src filename))
> +      (needsp (or (null pstamp) (< pstamp ctime)))
> +      includes)
> +    ;; if the file needs publishing, refresh the included-files cache 
> property

Comments need to start with a capital and end with a period.

> +    (when (and needsp
> +            (equal (file-name-extension filename) "org"))
> +      (let ((visiting (find-buffer-visiting filename))
> +         (buf (find-file-noselect (expand-file-name filename))))
> +     (with-current-buffer buf
> +       (save-excursion
> +         (goto-char (point-min))
> +         (while (re-search-forward "^[ \t]*#\\+INCLUDE:" nil t)
> +           (let* ((element (org-element-at-point))
> +                  (included-file
> +                   (and (eq (org-element-type element) 'keyword)
> +                        (let ((value (org-element-property :value element)))
> +                          (and value
> +                               (string-match "^\\(\".+?\"\\|\\S-+\\)" value)
> +                               (org-remove-double-quotes
> +                                (match-string 1 value)))))))
> +             (when included-file
> +               (add-to-list 'includes (expand-file-name included-file)))))))
> +     (unless visiting (kill-buffer buf))

Do not kill buffer yet, since you may re-open it later.

> +     (when includes
> +       (org-publish-cache-set-file-property filename :includes includes))))
> +    ;; return t if needsp or if included files have changed

Ditto.

> +    (or needsp
> +     (when (delq nil
> +                 (mapcar (lambda (file)
> +                           (let ((ct (org-publish-cache-ctime-of-src file)))
> +                             (and (file-exists-p file)
> +                                  (< ctime ct))))
> +                         (org-publish-cache-get-file-property filename 
> :includes)))

  (when (delq nil (mapcar PREDICATE LIST)))

=> 

  (org-some PREDICATE LIST)

> +       ;; update the timestamp of the published file if buffer is not 
> modified

Ditto.

> +       (let ((visiting (find-buffer-visiting filename))
> +             (buf (find-file-noselect (expand-file-name filename))))
> +         (with-current-buffer buf

Not needed if you didn't kill buffer yet.

> +           (when (not (buffer-modified-p))

  (unless ...)

> +             (set-buffer-modified-p t) (save-buffer)))

Hmm.  Would `set-file-times' do the job?

> +         (unless visiting (kill-buffer buf)))
> +       t))))

You can now kill-buffer, but for all cases.


Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]