- (if (and (eq (nth 0 state) 1)
- ;; This might be a docstring.
- (save-excursion
- (let ((n 0))
- (goto-char (nth 8 state))
- (condition-case nil
- (while (and (not (bobp))
- (progn (backward-sexp 1) (setq n (1+ n)))))
- (scan-error nil))
- (when (> n 0)
- (let ((sym (intern-soft
- (buffer-substring
- (point) (progn (forward-sexp 1) (point))))))
- (eq n (or (get sym 'doc-string-elt) 3)))))))
- font-lock-doc-face
- font-lock-string-face)
+ ;; This might be a (doc)string or a |...| symbol.
+ (let ((startpos (nth 8 state)))
+ (if (eq (char-after startpos) ?|)
+ ;; This is not a string, but a |...| symbol.
+ nil
+ (let* ((listbeg (nth 1 state))
+ (firstsym (and listbeg
+ (save-excursion
+ (goto-char listbeg)
+ (and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)")
+ (match-string 1)))))
+ (docelt (and firstsym (get (intern-soft firstsym)
+ lisp-doc-string-elt-property))))
+ (if (and docelt
+ ;; It's a string in a form that can have a docstring.
+ ;; Check whether it's in docstring position.
+ (save-excursion
+ (when (functionp docelt)
+ (goto-char (match-end 1))
+ (setq docelt (funcall docelt)))
+ (goto-char listbeg)
+ (forward-char 1)
+ (condition-case nil
+ (while (and (> docelt 0) (< (point) startpos)
+ (progn (forward-sexp 1) t))
+ (setq docelt (1- docelt)))
+ (error nil))
+ (and (zerop docelt) (<= (point) startpos)
+ (progn (forward-comment (point-max)) t)
+ (= (point) (nth 8 state)))))
+ font-lock-doc-face
+ font-lock-string-face))))