Commit cf530ebf authored by Jason Blevins's avatar Jason Blevins

Fix omission of generated files

* Add and update docstrings for checkdoc compliance.
* Fix issue with list order in deft-apply-generation-rules: check
  against entire files list instead of list of files processed so
  far.
* Rename deft-exported-from-previous? to deft-generated-file?
  Handle case where deft-generation-rules is nil. Use global
  deft-generation-rules rather than passing in a generic rules
  list.
parent 4e439d4f
......@@ -698,7 +698,8 @@ or kebab-case
:group 'deft)
(defcustom deft-generation-rules '(("org" . "tex") ("md" . "tex"))
"rules for omitting files autogenerated, for example, tex files generated from orgmode and pandoc"
"Rules for omitting automatically generated files.
For example, .tex files may be generated from `org-mode' or Pandoc."
:type '(repeat (cons string string))
:group 'deft)
......@@ -989,26 +990,30 @@ See `deft-find-all-files'."
(deft-apply-generation-rules result))))
(defun deft-apply-generation-rules (lst)
(let ((result nil))
(when deft-generation-rules
(dolist (file lst)
(when (not (deft-exported-from-previous? file deft-generation-rules result))
(setq result (cons file result))
)) result
)))
(defun deft-exported-from-previous? (file-name rules result)
"Apply `deft-generation-rules' to each file in LST.
Remove files which were likely automatically generated from others."
(if deft-generation-rules
(let ((result nil))
(dolist (file lst)
(when (not (deft-generated-file? file lst))
(setq result (cons file result))))
result)
lst))
(defun deft-generated-file? (file-name files)
"Determine whether FILE-NAME was likely generated from another in LST.
See `deft-generation-rules'."
(let ((val nil))
(dolist (rule rules)
(dolist (rule deft-generation-rules)
(let* ((orig-file-ext (file-name-extension file-name)))
(when (equal (cdr rule) orig-file-ext)
(let* ((new-file-ext (car rule))
(new-file-name (concat (file-name-sans-extension file-name) "." new-file-ext)))
(new-file-name (concat (file-name-sans-extension file-name)
"." new-file-ext)))
(when (not val)
(when (member new-file-name result)
(setq val t))))))) val))
(when (member new-file-name files)
(setq val t)))))))
val))
(defun deft-strip-title (title)
"Remove all strings matching `deft-strip-title-regexp' from TITLE."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment