Paul Sexton committed cec10f0

Fixed problem with 'syntax' section being at the wrong outline level for functions and macros.
The links at the top of the index section are now in alphabetical order, rather than a random jumble of letters.

Comments (0)

Files changed (2)

   (Note for mmm-mode users (see below): if the docstring starts with '###'
   to signal that it is in fact a docstring, CLOD will skip the hashes before
   looking to see if the string starts with a heading.)
-  So '=\"###* Arguments ...\"=' will work in that case.
+  So =\"###* Arguments ...\"= will work in that case.
 - Some symbol names used by common lisp can conflict with the markup used
   by org mode. For example, =*global-variable*=: asterisks are interpreted
   by org mode as signifying bold text. CLOD catches these in headings and
   "List of characters which are unsafe within HTML links and anchors, and
 which need to be converted to a safe representation.
-See also: [[html-safe-string]].")
+See also: [[html-safe-string]].
 (defun html-safe-string (str)
 remove or alter any unsafe characters that will stop the link working properly
 when the document is exported to HTML.
 * See Also
-- [[*unsafe-html-chars*]]"
+- [[*unsafe-html-chars*]]
   ;; If the link contains ':' then it represents a URL or other special
   ;; link, and is left alone.
   (if (and (stringp docstr)
            (string-starts-with? docstr (format nil "~C " *heading-char*)))
       (let ((*heading-level* (1+ *heading-level*)))
-        (write-docstring docstr :levels (1+ *heading-level*)))
+        (write-docstring docstr :levels *heading-level*))
       ;; else
       (writing-section (title)
         (write-docstring docstr))))
        (format nil
                "~%~{~A  ~}~%"
-                 (for (ch nil) in-hashtable index-table)
-                 (collect (format nil "[[index ~A][~A]]" ch ch)))))
+                 (for ch in (append *alphabet* (list 'nonalphabetic)))
+                 (if (gethash ch index-table)
+                     (collect (format nil "[[index ~A][~A]]" ch ch))))))
         (for ch in (cons 'nonalphabetic *alphabet*))
         (for syms = (gethash ch index-table))
     ;; We don't impose any structure (headings) on FUNCTION docstrings,
     ;; because functions are pretty opaque. It is up to the user to
     ;; write everything in the docstring.
-    (let ((*heading-level* (1+ *heading-level*)))
-      (write-lambda-list-section sym)
-      (write-docstring (documentation sym 'function)))))
+    (write-lambda-list-section sym)
+    (write-docstring-section "Description" (documentation sym 'function))))
 (defmethod document ((sym symbol) (doctype (eql :macro)))
   (writing-section-for-symbol (:macro sym)
     ;; The same goes for macros.
-    (let ((*heading-level* (1+ *heading-level*)))
-      (write-lambda-list-section sym)
-      (write-docstring (documentation sym 'function)))))
+    (write-lambda-list-section sym)
+    (write-docstring-section "Description" (documentation sym 'function))))
 ;;; using org mode, WITHIN lisp mode.
 ;;; See the CLOD documentation for details.
+;; First, add doc string fontification for some common lisp forms that
+;; lisp-mode.el omits.
+;; Can't do DEFMETHOD docstrings as defmethod form may contain :BEFORE,
+;; :AFTER etc.
+(put 'defparameter   'doc-string-elt 3)
+(put 'defconstant   'doc-string-elt 3)
+(put 'deftype   'doc-string-elt 3)
 ;;; Change this to the directory whwere nXhtml is installed.
 (add-to-list 'load-path (mkfilename *user-emacs-root* "/mmm-mode"))
 ;; The above, using major mode symbols, didn't seem to work for me so I
 ;; also added this line (regexp uses same format as major-mode-alist):
 (mmm-add-mode-ext-class nil  "\\.lisp$"  'org-submode)
+(mmm-add-mode-ext-class nil  "\\.lsp$"  'org-submode)
 (mmm-add-mode-ext-class nil  "\\.asd$"  'org-submode)
 (setq mmm-submode-decoration-level 2)
 ;; And the definition of 'org-submode
 (mmm-add-group 'org-submode
-               '((org-submode1
+               '((org-submode-1
                   :submode org-mode
                   :face mmm-declaration-submode-face
-                  :front "\""
-                  :back "[^\\]\""
+                  ;; Match '(:documentation "...")' docstrings
+                  :front "(:documentation[\t\n ]+\""
+                  ;; The following is a regexp, to match the end of a
+                  ;; string. Tolerates an EVEN number of backslashes
+                  ;; preceding the quote.
+                  :back "[^\\]\\(\\\\\\\\\\)*\"" ;"[^\\]\""
                   :back-offset 1
-                  :front-verify check-docstring-match
                   :end-not-begin t)
                   :submode org-mode
                   :face mmm-declaration-submode-face
-                  ;; Match '(:documentation "...")' docstrings
-                  :front "(:documentation[\t\n ]+\""
-                  :back "[^\\]\""
+                  :front "[^\\]\""
+                  :back "[^\\]\\(\\\\\\\\\\)*\"" ;"[^\\]\""
                   :back-offset 1
+                  :front-verify check-docstring-match
                   :end-not-begin t)))
 (defun face-at (pos)
   (let ((beg (match-beginning 0))
         (end (match-end 0)))
+   ;; If the character just BEFORE the match is in string face,
+   ;; the match will not be a doc string
+   ;((member (face-at beg) '(font-lock-doc-face font-lock-string-face))
+   ; nil)
    ;; Docstring if emacs has fontified it in 'docstring' face
    ((eql (face-at end) 'font-lock-doc-face)
    ;; quote are "###"
    ((string= (buffer-substring end (+ 3 end)) "###")
-   (t
-    nil))))
+   (t nil))))