Function: org-lint--collect-duplicates

org-lint--collect-duplicates is a byte-compiled function defined in org-lint.el.gz.

Signature

(org-lint--collect-duplicates AST TYPE EXTRACT-KEY EXTRACT-POSITION BUILD-MESSAGE)

Documentation

Helper function to collect duplicates in parse tree AST.

EXTRACT-KEY is a function extracting key. It is called with a single argument: the element or object. Comparison is done with equal.

EXTRACT-POSITION is a function returning position for the report. It is called with two arguments, the object or element, and the key.

BUILD-MESSAGE is a function creating the report message. It is called with one argument, the key used for comparison.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-lint.el.gz
;;; Checker functions

(defun org-lint--collect-duplicates
    (ast type extract-key extract-position build-message)
  "Helper function to collect duplicates in parse tree AST.

EXTRACT-KEY is a function extracting key.  It is called with
a single argument: the element or object.  Comparison is done
with `equal'.

EXTRACT-POSITION is a function returning position for the report.
It is called with two arguments, the object or element, and the
key.

BUILD-MESSAGE is a function creating the report message.  It is
called with one argument, the key used for comparison."
  (let* (keys
	 originals
	 reports
	 (make-report
	  (lambda (position value)
	    (push (list position (funcall build-message value)) reports))))
    (org-element-map ast type
      (lambda (datum)
	(let ((key (funcall extract-key datum)))
	  (cond
	   ((not key))
	   ((assoc key keys) (cl-pushnew (assoc key keys) originals)
	    (funcall make-report (funcall extract-position datum key) key))
	   (t (push (cons key (funcall extract-position datum key)) keys))))))
    (dolist (e originals reports) (funcall make-report (cdr e) (car e)))))