-;;; htmlfontify.el --- htmlise a buffer/source tree with optional hyperlinks
+;;; htmlfontify.el --- htmlize a buffer/source tree with optional hyperlinks
-;; Copyright (C) 2002-2003, 2009-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2009-2012 Free Software Foundation, Inc.
;; Emacs Lisp Archive Entry
;; Package: htmlfontify
;; Author: Vivek Dasmohapatra <vivek@etla.org>
;; Maintainer: Vivek Dasmohapatra <vivek@etla.org>
;; Created: 2002-01-05
-;; Description: htmlise a buffer/source tree with optional hyperlinks
+;; Description: htmlize a buffer/source tree with optional hyperlinks
;; URL: http://rtfm.etla.org/emacs/htmlfontify/
;; Compatibility: Emacs23, Emacs22
;; Incompatibility: Emacs19, Emacs20, Emacs21
:prefix "hfy-")
(defcustom hfy-page-header 'hfy-default-header
- "Function called to build the header of the html source.
+ "Function called to build the header of the HTML source.
This is called with two arguments (the filename relative to the top
level source directory being etag'd and fontified), and a string containing
the <style>...</style> text to embed in the document.
-It should return the string returned will be used as the header for the
+It should return a string that will be used as the header for the
htmlfontified version of the source file.\n
See also `hfy-page-footer'."
:group 'htmlfontify
(defcustom hfy-split-index nil
"Whether or not to split the index `hfy-index-file' alphabetically.
If non-nil, the index is split on the first letter of each tag.
-Useful when the index would otherwise
-be large and take a long time to render or be difficult to navigate."
+Useful when the index would otherwise be large and take
+a long time to render or be difficult to navigate."
:group 'htmlfontify
:tag "split-index"
:type '(boolean))
:tag "page-footer"
:type '(function))
-(defcustom hfy-extn ".html"
+(defcustom hfy-extn ".html"
"File extension used for output files."
:group 'htmlfontify
:tag "extension"
(defcustom hfy-post-html-hooks nil
"List of functions to call after creating and filling the HTML buffer.
-These functions will be called with the html buffer as the current buffer."
+These functions will be called with the HTML buffer as the current buffer."
:group 'htmlfontify
:tag "post-html-hooks"
:options '(set-auto-mode)
:group 'htmlfontify
:tag "html-quote-map"
:type '(alist :key-type (string)))
-(eval-and-compile
- (defconst hfy-e2x-etags-cmd "for src in `find . -type f`;
+(defconst hfy-e2x-etags-cmd "for src in `find . -type f`;
do
ETAGS=%s;
case ${src} in
esac;
done;")
- (defconst hfy-etags-cmd-alist-default
- `(("emacs etags" . ,hfy-e2x-etags-cmd)
- ("exuberant ctags" . "%s -R -f -" )))
+(defconst hfy-etags-cmd-alist-default
+ `(("emacs etags" . ,hfy-e2x-etags-cmd)
+ ("exuberant ctags" . "%s -R -f -" )))
- (defcustom hfy-etags-cmd-alist
- hfy-etags-cmd-alist-default
- "Alist of possible shell commands that will generate etags output that
+(defcustom hfy-etags-cmd-alist
+ hfy-etags-cmd-alist-default
+ "Alist of possible shell commands that will generate etags output that
`htmlfontify' can use. '%s' will be replaced by `hfy-etags-bin'."
- :group 'htmlfontify
- :tag "etags-cmd-alist"
- :type '(alist :key-type (string) :value-type (string)) ))
+ :group 'htmlfontify
+ :tag "etags-cmd-alist"
+ :type '(alist :key-type (string) :value-type (string)))
(defcustom hfy-etags-bin "etags"
"Location of etags binary (we begin by assuming it's in your path).\n
:type '(file))
(defcustom hfy-shell-file-name "/bin/sh"
- "Shell (bourne or compatible) to invoke for complex shell operations."
+ "Shell (Bourne or compatible) to invoke for complex shell operations."
:group 'htmlfontify
:tag "shell-file-name"
:type '(file))
:type '(repeat symbol))
(defun hfy-which-etags ()
- "Return a string indicating which flavour of etags we are using."
+ "Return a string indicating which flavor of etags we are using."
(let ((v (shell-command-to-string (concat hfy-etags-bin " --version"))))
(cond ((string-match "exube" v) "exuberant ctags")
((string-match "GNU E" v) "emacs etags" )) ))
(defcustom hfy-etags-cmd
- (eval-and-compile (cdr (assoc (hfy-which-etags) hfy-etags-cmd-alist)))
+ ;; We used to wrap this in a `eval-and-compile', but:
+ ;; - it had no effect because this expression was not seen by the
+ ;; byte-compiler (defcustom used to quote this argument).
+ ;; - it signals an error (`hfy-which-etags' is not defined at compile-time).
+ ;; - we want this auto-detection to reflect the system on which Emacs is run
+ ;; rather than the one on which it's compiled.
+ (cdr (assoc (hfy-which-etags) hfy-etags-cmd-alist))
"The etags equivalent command to run in a source directory to generate a tags
file for the whole source tree from there on down. The command should emit
the etags output on stdout.\n
exuberant-ctags' etags respectively."
:group 'htmlfontify
:tag "etags-command"
- :type (eval-and-compile
- (let ((clist (list '(string))))
- (dolist (C hfy-etags-cmd-alist)
- (push (list 'const :tag (car C) (cdr C)) clist))
- (cons 'choice clist)) ))
+ :type (let ((clist (list '(string))))
+ (dolist (C hfy-etags-cmd-alist)
+ (push (list 'const :tag (car C) (cdr C)) clist))
+ (cons 'choice clist)))
(defcustom hfy-istext-command "file %s | sed -e 's@^[^:]*:[ \t]*@@'"
"Command to run with the name of a file, to see whether it is a text file
(const :tag "Lucid Toolkit" lucid )
(const :tag "Motif Toolkit" motif )))
- (class (choice (const :tag "Colour" color )
- (const :tag "Greyscale" grayscale)))
+ (class (choice (const :tag "Color" color )
+ (const :tag "Grayscale" grayscale)))
(background (choice (const :tag "Dark" dark )
(const :tag "Bright" light ))) ))
(color-values colour)
;;(message "[%S]" window-system)
(x-color-values colour))
- ;; blarg - tty colours are no good - go fetch some X colours:
+ ;; blarg - tty colors are no good - go fetch some X colors:
(hfy-fallback-colour-values colour))))
(defvar hfy-cperl-mode-kludged-p nil)
(defun hfy-kludge-cperl-mode ()
- "CPerl mode does its damndest not to do some of its fontification when not
+ "CPerl mode does its damnedest not to do some of its fontification when not
in a windowing system - try to trick it..."
(if (not hfy-cperl-mode-kludged-p)
(progn (if (not window-system)
(setq cperl-syntaxify-by-font-lock t)))
(setq hfy-cperl-mode-kludged-p t))) )
-(defun hfy-opt (symbol) "Is option SYMBOL set."
+(defun hfy-opt (symbol)
+ "Is option SYMBOL set."
(memq symbol hfy-optimisations))
(defun hfy-default-header (file style)
<body onload=\"stripe('index'); return true;\">\n"
file style))
-(defun hfy-default-footer (file)
+(defun hfy-default-footer (_file)
"Default value for `hfy-page-footer'.
FILE is the name of the file being rendered, in case it is needed."
"\n </body>\n</html>\n")
((stringp box) (list (cons "border" (format "solid %s 1px" box))))
((listp box) (hfy-box-to-style box) ))) )
-(defun hfy-decor (tag val)
+(defun hfy-decor (tag _val)
"Derive CSS text-decoration specifiers from various Emacs font attributes.
TAG is an Emacs font attribute key (eg :underline).
VAL is ignored."
(:overline (cons "text-decoration" "overline" ))
(:strike-through (cons "text-decoration" "line-through")))))
-(defun hfy-invisible (&optional val)
+(defun hfy-invisible (&optional _val)
"This text should be invisible.
Do something in CSS to make that happen.
VAL is ignored here."
;; text-decoration is not inherited.
;; but it's not wrong and if this ever changes it will
;; be needed, so I think it's better to leave it in? -- v
- (nconc final-style '(("text-decoration"."none"))))))
+ (nconc final-style '(("text-decoration" . "none"))))))
final-style))
;; strip redundant bits from a name. Technically, this could result in
(setq p (next-char-property-change p)))
;; still invisible at buffer end?
(when i
- (setq invisible (cons (cons s (point-max)) invisible)))
+ (setq invisible (cons (cons s (point-max)) invisible)))
invisible)))
(defun hfy-invisible-name (point map)
(delete-overlay rovl))
(copy-to-buffer html-buffer (point-min) (point-max))
(set-buffer html-buffer)
- ;; rip out props that could interfere with our htmlisation of the buffer:
+ ;; rip out props that could interfere with our htmlization of the buffer:
(remove-text-properties (point-min) (point-max) hfy-ignored-properties)
;; Apply overlay invisible spec
(setq orig-ovls
(if (not (hfy-opt 'skip-refontification))
(save-excursion ;; Keep region
(hfy-force-fontification)))
- (if (interactive-p) ;; display the buffer in interactive mode:
+ (if (called-interactively-p 'any) ;; display the buffer in interactive mode:
(switch-to-buffer (hfy-fontify-buffer srcdir file))
(hfy-fontify-buffer srcdir file)))
"Return a list of files under DIRECTORY.
Strips any leading \"./\" from each filename."
;;(message "hfy-list-files");;DBUG
- ;; FIXME: this changes the dir of the currrent buffer. Is that right??
+ ;; FIXME: this changes the dir of the current buffer. Is that right??
(cd directory)
(mapcar (lambda (F) (if (string-match "^./\\(.*\\)" F) (match-string 1 F) F))
(split-string (shell-command-to-string hfy-find-cmd))) )
-;; strip the filename off, return a directiry name
-;; not a particularly thorough implementaion, but it will be
+;; strip the filename off, return a directory name
+;; not a particularly thorough implementation, but it will be
;; fed pretty carefully, so it should be Ok:
(defun hfy-dirname (file)
"Return everything preceding the last \"/\" from a relative filename FILE,
tags-list) )))
(defun hfy-shell ()
- "Return `shell-file-name', or \"/bin/sh\" if it is a non-bourne shell."
+ "Return `shell-file-name', or \"/bin/sh\" if it is a non-Bourne shell."
(if (string-match "\\<bash\\>\\|\\<sh\\>\\|\\<dash\\>" shell-file-name)
shell-file-name
(or hfy-shell-file-name "/bin/sh")))
(hash-entry nil) (tag-string nil) (tag-line nil)
(tag-point nil) (new-entry nil) (etags-file nil))
- ;; (re)initialise the tag reverse map:
+ ;; (re)initialize the tag reverse map:
(if trmap-cache (setq trmap-hash (cadr trmap-cache))
(setq trmap-hash (make-hash-table :test 'equal))
(setq hfy-tags-rmap (list (list srcdir trmap-hash) hfy-tags-rmap)))
(clrhash trmap-hash)
- ;; (re)initialise the tag cache:
+ ;; (re)initialize the tag cache:
(if cache-entry (setq cache-hash (cadr cache-entry))
(setq cache-hash (make-hash-table :test 'equal))
(setq hfy-tags-cache (list (list srcdir cache-hash) hfy-tags-cache)))
(puthash tag-string hash-entry cache-hash)))) )))
;; cache a list of tags in descending length order:
- (maphash (lambda (K V) (push K tags-list)) cache-hash)
+ (maphash (lambda (K _V) (push K tags-list)) cache-hash)
(setq tags-list (sort tags-list (lambda (A B) (< (length B) (length A)))))
;; put the tag list into the cache:
(setq cache-hash (cadr cache-entry))
(setq index-buf (get-buffer-create index-file))))
nil ;; noop
- (maphash (lambda (K V) (push K tag-list)) cache-hash)
+ (maphash (lambda (K _V) (push K tag-list)) cache-hash)
(setq tag-list (sort tag-list 'string<))
(set-buffer index-buf)
(erase-buffer)
(cache-entry (assoc srcdir hfy-tags-cache)))
(if (and cache-entry (setq cache-hash (cadr cache-entry)))
(maphash
- (lambda (K V)
+ (lambda (K _V)
(let ((stub (upcase (substring K 0 1))))
(if (member stub stub-list)
nil ;; seen this already: NOOP
(if (and cache-entry (setq cache-hash (cadr cache-entry)))
(maphash
- (lambda (K V)
+ (lambda (K _V)
(let ((stub (upcase (substring K 0 1))))
(if (member stub stub-list)
nil ;; seen this already: NOOP