From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Matt Lundin <mdl@imapmail.org>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Fix and optimize publishing cache check
Date: Thu, 14 Aug 2014 11:13:32 +0200 [thread overview]
Message-ID: <878umr4eo3.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87d2c5xb5a.fsf@fastmail.fm> (Matt Lundin's message of "Tue, 12 Aug 2014 23:32:17 -0500")
Hello,
Matt Lundin <mdl@imapmail.org> 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
prev parent reply other threads:[~2014-08-14 9:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-12 13:09 [PATCH] Fix and optimize publishing cache check Matt Lundin
2014-08-13 4:32 ` Matt Lundin
2014-08-14 9:13 ` Nicolas Goaziou [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878umr4eo3.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=mdl@imapmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).