Function: checkdoc-message-text-engine

checkdoc-message-text-engine is a byte-compiled function defined in checkdoc.el.gz.

Signature

(checkdoc-message-text-engine &optional TYPE)

Documentation

Return or fix errors found in strings passed to a message display function.

According to the documentation for the function error, the error list should not end with a period, and should start with a capital letter. The function y-or-n-p has similar constraints. Argument TYPE specifies the type of question, such as error or y-or-n-p.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/checkdoc.el.gz
(defun checkdoc-message-text-engine (&optional type)
  "Return or fix errors found in strings passed to a message display function.
According to the documentation for the function `error', the error list
should not end with a period, and should start with a capital letter.
The function `y-or-n-p' has similar constraints.
Argument TYPE specifies the type of question, such as `error' or `y-or-n-p'."
  ;; If type is nil, then attempt to derive it.
  (if (not type)
      (save-excursion
	(up-list -1)
	(if (looking-at "(format")
	    (up-list -1))
	(setq type
	      (cond ((looking-at "(error")
		     'error)
		    (t 'y-or-n-p)))))
  (let ((case-fold-search nil))
    (or
     ;; From the documentation of the symbol `error':
     ;; In Emacs, the convention is that error messages start with a capital
     ;; letter but *do not* end with a period.  Please follow this convention
     ;; for the sake of consistency.
     (if (and (checkdoc--error-bad-format-p)
	      (not (checkdoc-autofix-ask-replace
                    (match-beginning 1) (match-end 1)
                    "Capitalize your message text?"
                    (capitalize (match-string 1))
		    t)))
         (checkdoc-create-error "Messages should start with a capital letter"
          (match-beginning 1) (match-end 1))
       nil)
     ;; In general, sentences should have two spaces after the period.
     (checkdoc-sentencespace-region-engine (point)
					   (save-excursion (forward-sexp 1)
							   (point)))
     ;; Look for proper nouns in this region too.
     (checkdoc-proper-noun-region-engine (point)
					 (save-excursion (forward-sexp 1)
							 (point)))
     ;; Here are message type specific questions.
     (if (and (eq type 'error)
	      (save-excursion (forward-sexp 1)
			      (forward-char -2)
			      (looking-at "\\."))
	      (not (checkdoc-autofix-ask-replace (match-beginning 0)
						 (match-end 0)
                                                 "Remove period from error?"
						 ""
						 t)))
	 (checkdoc-create-error
	  "Error messages should *not* end with a period"
	  (match-beginning 0) (match-end 0))
       nil)
     ;; From `(elisp) Programming Tips': "A question asked in the
     ;; minibuffer with `yes-or-no-p' or `y-or-n-p' should start with
     ;; a capital letter and end with '?'."
     (when (eq type 'y-or-n-p)
       (checkdoc--fix-y-or-n-p))
     ;; Now, let's just run the spell checker on this guy.
     (checkdoc-ispell-docstring-engine (save-excursion (forward-sexp 1)
                                                       (point))))))