Function: org-cmp-alpha

org-cmp-alpha is a byte-compiled function defined in org-agenda.el.gz.

Signature

(org-cmp-alpha A B)

Documentation

Compare the headlines, alphabetically.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-agenda.el.gz
(defsubst org-cmp-alpha (a b)
  "Compare the headlines, alphabetically."
  (let* ((pla (text-property-any 0 (length a) 'org-heading t a))
	 (plb (text-property-any 0 (length b) 'org-heading t b))
	 (ta (and pla (substring a pla)))
	 (tb (and plb (substring b plb)))
	 (case-fold-search nil))
    (when pla
      (when (string-match (concat "\\`[ \t]*" (or (get-text-property 0 'org-todo-regexp a) "")
				  "\\([ \t]*\\[[a-zA-Z0-9]\\]\\)? *")
			  ta)
	(setq ta (substring ta (match-end 0))))
      (setq ta (downcase ta)))
    (when plb
      (when (string-match (concat "\\`[ \t]*" (or (get-text-property 0 'org-todo-regexp b) "")
				  "\\([ \t]*\\[[a-zA-Z0-9]\\]\\)? *")
			  tb)
	(setq tb (substring tb (match-end 0))))
      (setq tb (downcase tb)))
    (cond ((not (or ta tb)) nil)
	  ((not ta) +1)
	  ((not tb) -1)
	  ((org-string< ta tb) -1)
	  ((org-string< tb ta) +1))))