# HG changeset patch # User Gerd Moellmann # Date 945767321 0 # Node ID f281dfbf8cd26f807373013fcc9b6915d294404b # Parent 6bdad766098e5dd283776c83288d27857ce2de8c *** empty log message *** diff -r 6bdad766098e -r f281dfbf8cd2 lisp/ChangeLog --- a/lisp/ChangeLog Mon Dec 20 23:09:55 1999 +0000 +++ b/lisp/ChangeLog Tue Dec 21 09:08:41 1999 +0000 @@ -1,3 +1,7 @@ +1999-12-21 Gerd Moellmann + + * progmodes/cwarn.el: New file. + 1999-12-19 Gerd Moellmann * bindings.el (completion-ignored-extensions): Add .pdf. diff -r 6bdad766098e -r f281dfbf8cd2 lisp/cus-load.el --- a/lisp/cus-load.el Mon Dec 20 23:09:55 1999 +0000 +++ b/lisp/cus-load.el Tue Dec 21 09:08:41 1999 +0000 @@ -13,6 +13,7 @@ (put 'nnmail 'custom-loads '("nnmail")) (put 'chistory 'custom-loads '("chistory")) (put 'shell-directories 'custom-loads '("shell")) +(put 'footnote 'custom-loads '("footnote")) (put 'calendar-tex 'custom-loads '("cal-tex")) (put 'mail-hist 'custom-loads '("mail-hist")) (put 'gnus-article-emphasis 'custom-loads '("gnus-art")) @@ -77,6 +78,7 @@ (put 'info-lookup 'custom-loads '("info-look")) (put 'show-tabs 'custom-loads '("generic-x")) (put 'gnus-various 'custom-loads '("gnus-sum" "gnus")) +(put 'elide-head 'custom-loads '("elide-head")) (put 'vhdl-compile 'custom-loads '("vhdl-mode")) (put 'font-lock-highlighting-faces 'custom-loads '("font-lock" "vhdl-mode")) (put 'flyspell 'custom-loads '("flyspell")) @@ -162,6 +164,7 @@ (put 'gnus-threading 'custom-loads '("gnus-sum")) (put 'hide-ifdef 'custom-loads '("hideif")) (put 'vip 'custom-loads '("vip")) +(put 'smerge 'custom-loads '("smerge-mode")) (put 'spell 'custom-loads '("spell")) (put 'rmail-headers 'custom-loads '("rmail")) (put 'gnus-score-decay 'custom-loads '("gnus-score")) @@ -214,6 +217,7 @@ (put 'PostScript-interaction 'custom-loads '("ps-mode")) (put 'ps-print 'custom-loads '("ps-print")) (put 'view 'custom-loads '("view" "calendar")) +(put 'cwarn 'custom-loads '("cwarn")) (put 'gnus-score-default 'custom-loads '("gnus-score" "gnus-sum")) (put 'nnmail-duplicate 'custom-loads '("nnmail")) (put 'handwrite 'custom-loads '("handwrite")) @@ -245,7 +249,7 @@ (put 'gnus-summary-mail 'custom-loads '("gnus-sum")) (put 'apropos 'custom-loads '("apropos")) (put 'gomoku 'custom-loads '("gomoku")) -(put 'tools 'custom-loads '("add-log" "compare-w" "diff-mode" "diff" "ediff" "emerge" "gud" "rcompile" "speedbar" "tempo" "tooltip" "vc" "which-func" "copyright" "compile" "etags" "make-mode")) +(put 'tools 'custom-loads '("add-log" "compare-w" "diff-mode" "diff" "ediff" "elide-head" "emerge" "gud" "rcompile" "smerge-mode" "speedbar" "tempo" "tooltip" "vc" "which-func" "copyright" "compile" "etags" "make-mode")) (put 'gnus-topic 'custom-loads '("gnus-topic")) (put 'sgml 'custom-loads '("sgml-mode")) (put 'keyboard 'custom-loads '("simple" "chistory" "type-break")) @@ -371,7 +375,7 @@ (put 'archive-zoo 'custom-loads '("arc-mode")) (put 'gnus-group-level 'custom-loads '("gnus")) (put 'bibtex 'custom-loads '("bibtex")) -(put 'faces 'custom-loads '("faces" "facemenu" "cus-edit" "font-lock" "hilit-chg" "paren" "ps-print" "speedbar" "wid-edit" "gnus" "message" "fontset" "make-mode")) +(put 'faces 'custom-loads '("faces" "facemenu" "cus-edit" "font-lock" "hilit-chg" "paren" "ps-print" "speedbar" "wid-edit" "gnus" "message" "fontset" "cwarn" "make-mode")) (put 'fill-comments 'custom-loads '("simple")) (put 'gnus-summary-various 'custom-loads '("gnus-sum")) (put 'applications 'custom-loads '("calendar" "cus-edit" "uniquify" "spell")) @@ -388,7 +392,7 @@ (put 'debug 'custom-loads '("debug")) (put 'vhdl-electric 'custom-loads '("vhdl-mode")) (put 'gnus-extract-archive 'custom-loads '("gnus-uu")) -(put 'message 'custom-loads '("startup" "message")) +(put 'message 'custom-loads '("startup" "message" "footnote")) (put 'message-sending 'custom-loads '("message")) (put 'archive-arc 'custom-loads '("arc-mode")) (put 'rmail-output 'custom-loads '("rmailout")) @@ -433,7 +437,7 @@ (put 'widget-button 'custom-loads '("wid-edit")) (put 'uniquify 'custom-loads '("uniquify")) (put 'old-c++ 'custom-loads '("cplus-md")) -(put 'ps-print-font 'custom-loads '("ps-print")) +(put 'ps-print-font 'custom-loads '("ps-print" "ps-vars")) (put 'vhdl-misc 'custom-loads '("vhdl-mode")) (put 'dired-x 'custom-loads '("dired-x")) (put 'spook 'custom-loads '("spook")) diff -r 6bdad766098e -r f281dfbf8cd2 lisp/loaddefs.el --- a/lisp/loaddefs.el Mon Dec 20 23:09:55 1999 +0000 +++ b/lisp/loaddefs.el Tue Dec 21 09:08:41 1999 +0000 @@ -983,7 +983,7 @@ ;;;;;; bookmark-load bookmark-save bookmark-write bookmark-delete ;;;;;; bookmark-insert bookmark-rename bookmark-insert-location ;;;;;; bookmark-relocate bookmark-jump bookmark-set) "bookmark" -;;;;;; "bookmark.el" (14415 13511)) +;;;;;; "bookmark.el" (14419 37278)) ;;; Generated autoloads from bookmark.el (define-key ctl-x-map "rb" 'bookmark-jump) (define-key ctl-x-map "rm" 'bookmark-set) @@ -1446,7 +1446,7 @@ ;;;### (autoloads (batch-byte-recompile-directory batch-byte-compile ;;;;;; display-call-tree byte-compile compile-defun byte-compile-file ;;;;;; byte-recompile-directory byte-force-recompile) "bytecomp" -;;;;;; "emacs-lisp/bytecomp.el" (14297 56999)) +;;;;;; "emacs-lisp/bytecomp.el" (14425 19316)) ;;; Generated autoloads from emacs-lisp/bytecomp.el (autoload (quote byte-force-recompile) "bytecomp" "\ @@ -2238,7 +2238,7 @@ ;;;;;; checkdoc-continue checkdoc-start checkdoc-current-buffer ;;;;;; checkdoc-eval-current-buffer checkdoc-message-interactive ;;;;;; checkdoc-interactive checkdoc) "checkdoc" "emacs-lisp/checkdoc.el" -;;;;;; (14398 50288)) +;;;;;; (14412 8749)) ;;; Generated autoloads from emacs-lisp/checkdoc.el (autoload (quote checkdoc) "checkdoc" "\ @@ -2774,7 +2774,7 @@ ;;;### (autoloads (decompose-composite-char compose-last-chars compose-chars-after ;;;;;; find-composition compose-chars decompose-string compose-string ;;;;;; decompose-region compose-region) "composite" "composite.el" -;;;;;; (14422 54140)) +;;;;;; (14422 57499)) ;;; Generated autoloads from composite.el (defconst reference-point-alist (quote ((tl . 0) (tc . 1) (tr . 2) (Bl . 3) (Bc . 4) (Br . 5) (bl . 6) (bc . 7) (br . 8) (cl . 9) (cc . 10) (cr . 11) (top-left . 0) (top-center . 1) (top-right . 2) (base-left . 3) (base-center . 4) (base-right . 5) (bottom-left . 6) (bottom-center . 7) (bottom-right . 8) (center-left . 9) (center-center . 10) (center-right . 11) (ml . 3) (mc . 10) (mr . 5) (mid-left . 3) (mid-center . 10) (mid-right . 5))) "\ @@ -3222,7 +3222,7 @@ ;;;;;; customize-option-other-window customize-changed-options customize-option ;;;;;; customize-group-other-window customize-group customize customize-save-variable ;;;;;; customize-set-variable customize-set-value) "cus-edit" "cus-edit.el" -;;;;;; (14417 23470)) +;;;;;; (14419 37278)) ;;; Generated autoloads from cus-edit.el (add-hook 'same-window-regexps "\\`\\*Customiz.*\\*\\'") @@ -3401,6 +3401,32 @@ ;;;*** +;;;### (autoloads (global-cwarn-mode turn-on-cwarn-mode cwarn-mode) +;;;;;; "cwarn" "progmodes/cwarn.el" (14431 15379)) +;;; Generated autoloads from progmodes/cwarn.el + +(autoload (quote cwarn-mode) "cwarn" "\ +Minor mode that hightlight suspicious C and C++ constructions. + +Note, in addition to enabling this minor mode, the major mode must +be included in the variable `cwarn-configuration'. By default C and +C++ modes are included. + +With ARG, turn CWarn mode on if and only if arg is positive." t nil) + +(autoload (quote turn-on-cwarn-mode) "cwarn" "\ +Turn on CWarn mode. + +This function is designed to be added to hooks, for example: + (add-hook 'c-mode-hook 'turn-on-cwarn-mode)" nil nil) + +(autoload (quote global-cwarn-mode) "cwarn" "\ +Hightlight suspicious C and C++ constructions in all buffers. + +With ARG, turn CWarn mode on globally if and only if arg is positive." t nil) + +;;;*** + ;;;### (autoloads (standard-display-cyrillic-translit cyrillic-encode-alternativnyj-char ;;;;;; cyrillic-encode-koi8-r-char setup-cyrillic-alternativnyj-environment ;;;;;; setup-cyrillic-koi8-environment setup-cyrillic-iso-environment) @@ -3604,7 +3630,7 @@ ;;;*** ;;;### (autoloads (cancel-debug-on-entry debug-on-entry debug) "debug" -;;;;;; "emacs-lisp/debug.el" (14385 24854)) +;;;;;; "emacs-lisp/debug.el" (14428 55109)) ;;; Generated autoloads from emacs-lisp/debug.el (setq debugger (quote debug)) @@ -3815,7 +3841,7 @@ ;;;;;; devanagari-decompose-string char-to-glyph-devanagari indian-to-devanagari-string ;;;;;; devanagari-to-indian-region indian-to-devanagari-region devanagari-to-indian ;;;;;; indian-to-devanagari setup-devanagari-environment) "devan-util" -;;;;;; "language/devan-util.el" (14422 54140)) +;;;;;; "language/devan-util.el" (14423 51006)) ;;; Generated autoloads from language/devan-util.el (autoload (quote setup-devanagari-environment) "devan-util" "\ @@ -3931,7 +3957,7 @@ ;;;*** ;;;### (autoloads (diff-minor-mode diff-mode) "diff-mode" "diff-mode.el" -;;;;;; (14412 45411)) +;;;;;; (14419 37278)) ;;; Generated autoloads from diff-mode.el (autoload (quote diff-mode) "diff-mode" "\ @@ -3951,7 +3977,7 @@ ;;;;;; dired dired-copy-preserve-time dired-dwim-target dired-keep-marker-symlink ;;;;;; dired-keep-marker-hardlink dired-keep-marker-copy dired-keep-marker-rename ;;;;;; dired-trivial-filenames dired-ls-F-marks-symlinks dired-listing-switches) -;;;;;; "dired" "dired.el" (14349 51336)) +;;;;;; "dired" "dired.el" (14425 19313)) ;;; Generated autoloads from dired.el (defvar dired-listing-switches "-al" "\ @@ -4055,7 +4081,7 @@ ;;;;;; dired-do-compress dired-compress-file dired-do-kill-lines ;;;;;; dired-do-shell-command dired-do-print dired-do-chown dired-do-chgrp ;;;;;; dired-do-chmod dired-backup-diff dired-diff) "dired-aux" -;;;;;; "dired-aux.el" (14415 3380)) +;;;;;; "dired-aux.el" (14419 37278)) ;;; Generated autoloads from dired-aux.el (autoload (quote dired-diff) "dired-aux" "\ @@ -4992,8 +5018,8 @@ ;;;*** -;;;### (autoloads (elide-head) "elide-head" "elide-head.el" (14409 -;;;;;; 5684)) +;;;### (autoloads (elide-head) "elide-head" "elide-head.el" (14425 +;;;;;; 19313)) ;;; Generated autoloads from elide-head.el (autoload (quote elide-head) "elide-head" "\ @@ -5579,7 +5605,7 @@ ;;;*** ;;;### (autoloads (expand-jump-to-next-slot expand-jump-to-previous-slot -;;;;;; expand-add-abbrevs) "expand" "expand.el" (14001 49633)) +;;;;;; expand-add-abbrevs) "expand" "expand.el" (14428 51143)) ;;; Generated autoloads from expand.el (autoload (quote expand-add-abbrevs) "expand" "\ @@ -5684,7 +5710,7 @@ ;;;;;; facemenu-remove-special facemenu-remove-all facemenu-remove-face-props ;;;;;; facemenu-set-read-only facemenu-set-intangible facemenu-set-invisible ;;;;;; facemenu-set-face-from-menu facemenu-set-background facemenu-set-foreground -;;;;;; facemenu-set-face) "facemenu" "facemenu.el" (14411 63600)) +;;;;;; facemenu-set-face) "facemenu" "facemenu.el" (14412 8701)) ;;; Generated autoloads from facemenu.el (define-key global-map "\M-g" 'facemenu-keymap) (autoload 'facemenu-keymap "facemenu" "Keymap for face-changing commands." t 'keymap) @@ -5890,7 +5916,7 @@ ;;;*** ;;;### (autoloads (dired-at-point ffap-at-mouse ffap-menu find-file-at-point -;;;;;; ffap-next) "ffap" "ffap.el" (14411 58300)) +;;;;;; ffap-next) "ffap" "ffap.el" (14412 8705)) ;;; Generated autoloads from ffap.el (autoload (quote ffap-next) "ffap" "\ @@ -6278,7 +6304,7 @@ ;;;### (autoloads (font-lock-fontify-buffer global-font-lock-mode ;;;;;; global-font-lock-mode font-lock-remove-keywords font-lock-add-keywords ;;;;;; turn-on-font-lock font-lock-mode) "font-lock" "font-lock.el" -;;;;;; (14415 42514)) +;;;;;; (14424 65029)) ;;; Generated autoloads from font-lock.el (defvar font-lock-mode-hook nil "\ @@ -6362,8 +6388,10 @@ `objc-font-lock-extra-types' and `java-font-lock-extra-types'." nil nil) (autoload (quote font-lock-remove-keywords) "font-lock" "\ -Remove highlighting KEYWORDS from the current buffer. -A non-nil MODE is currently unsupported." nil nil) +Remove highlighting KEYWORDS for MAJOR-MODE. + +MAJOR-MODE should be a symbol, the major mode command name, such as `c-mode' +or nil. If nil, highlighting keywords are removed for the current buffer." nil nil) (autoload (quote global-font-lock-mode) "font-lock" "\ Toggle Global Font Lock mode. @@ -6391,7 +6419,7 @@ ;;;*** ;;;### (autoloads (create-fontset-from-fontset-spec) "fontset" "international/fontset.el" -;;;;;; (14422 54140)) +;;;;;; (14423 50991)) ;;; Generated autoloads from international/fontset.el (autoload (quote create-fontset-from-fontset-spec) "fontset" "\ @@ -6414,6 +6442,26 @@ ;;;*** +;;;### (autoloads (footnote-mode) "footnote" "mail/footnote.el" (14423 +;;;;;; 51009)) +;;; Generated autoloads from mail/footnote.el + +(autoload (quote footnote-mode) "footnote" "\ +Toggle footnote minor mode. +\\ +key binding +--- ------- + +\\[Footnote-renumber-footnotes] Footnote-renumber-footnotes +\\[Footnote-goto-footnote] Footnote-goto-footnote +\\[Footnote-delete-footnote] Footnote-delete-footnote +\\[Footnote-cycle-style] Footnote-cycle-style +\\[Footnote-back-to-message] Footnote-back-to-message +\\[Footnote-add-footnote] Footnote-add-footnote +" t nil) + +;;;*** + ;;;### (autoloads (forms-find-file-other-window forms-find-file forms-mode) ;;;;;; "forms" "forms.el" (14381 57540)) ;;; Generated autoloads from forms.el @@ -7690,7 +7738,7 @@ ;;;### (autoloads (Info-speedbar-browser Info-goto-emacs-key-command-node ;;;;;; Info-goto-emacs-command-node info-standalone info info-other-window) -;;;;;; "info" "info.el" (14411 63935)) +;;;;;; "info" "info.el" (14412 8715)) ;;; Generated autoloads from info.el (autoload (quote info-other-window) "info" "\ @@ -8395,7 +8443,7 @@ ;;;### (autoloads (lao-composition-function lao-transcribe-roman-to-lao-string ;;;;;; lao-transcribe-single-roman-syllable-to-lao lao-compose-string ;;;;;; setup-lao-environment) "lao-util" "language/lao-util.el" -;;;;;; (14422 54141)) +;;;;;; (14423 51007)) ;;; Generated autoloads from language/lao-util.el (autoload (quote setup-lao-environment) "lao-util" "\ @@ -8614,7 +8662,7 @@ ;;;*** -;;;### (autoloads nil "ls-lisp" "ls-lisp.el" (14251 18531)) +;;;### (autoloads nil "ls-lisp" "ls-lisp.el" (14425 19316)) ;;; Generated autoloads from ls-lisp.el (defvar ls-lisp-support-shell-wildcards t "\ @@ -9530,7 +9578,7 @@ ;;;;;; coding-system-post-read-conversion coding-system-eol-type-mnemonic ;;;;;; lookup-nested-alist set-nested-alist truncate-string-to-width ;;;;;; store-substring string-to-sequence) "mule-util" "international/mule-util.el" -;;;;;; (14422 54140)) +;;;;;; (14423 50997)) ;;; Generated autoloads from international/mule-util.el (autoload (quote string-to-sequence) "mule-util" "\ @@ -10376,8 +10424,8 @@ ;;;### (autoloads (ps-mule-begin-page ps-mule-begin-job ps-mule-initialize ;;;;;; ps-mule-plot-composition ps-mule-plot-string ps-mule-set-ascii-font -;;;;;; ps-mule-prepare-ascii-font) "ps-mule" "ps-mule.el" (14422 -;;;;;; 54141)) +;;;;;; ps-mule-prepare-ascii-font) "ps-mule" "ps-mule.el" (14423 +;;;;;; 50875)) ;;; Generated autoloads from ps-mule.el (autoload (quote ps-mule-prepare-ascii-font) "ps-mule" "\ @@ -10430,8 +10478,8 @@ ;;;;;; ps-nb-pages-buffer ps-line-lengths ps-despool ps-spool-region-with-faces ;;;;;; ps-spool-region ps-spool-buffer-with-faces ps-spool-buffer ;;;;;; ps-print-region-with-faces ps-print-region ps-print-buffer-with-faces -;;;;;; ps-print-buffer ps-paper-type) "ps-print" "ps-print.el" (14422 -;;;;;; 54141)) +;;;;;; ps-print-buffer ps-paper-type) "ps-print" "ps-print.el" (14423 +;;;;;; 50877)) ;;; Generated autoloads from ps-print.el (defvar ps-paper-type (quote letter) "\ @@ -10565,7 +10613,7 @@ ;;;### (autoloads (quail-update-leim-list-file quail-defrule-internal ;;;;;; quail-defrule quail-install-map quail-define-rules quail-set-keyboard-layout ;;;;;; quail-define-package quail-use-package) "quail" "international/quail.el" -;;;;;; (14422 54140)) +;;;;;; (14423 51000)) ;;; Generated autoloads from international/quail.el (autoload (quote quail-use-package) "quail" "\ @@ -10891,7 +10939,7 @@ ;;;*** ;;;### (autoloads (reftex-mode turn-on-reftex) "reftex" "textmodes/reftex.el" -;;;;;; (14315 19661)) +;;;;;; (14425 19353)) ;;; Generated autoloads from textmodes/reftex.el (autoload (quote turn-on-reftex) "reftex" "\ @@ -10931,7 +10979,7 @@ ;;;*** ;;;### (autoloads (reftex-citation) "reftex-cite" "textmodes/reftex-cite.el" -;;;;;; (14315 19188)) +;;;;;; (14425 19348)) ;;; Generated autoloads from textmodes/reftex-cite.el (autoload (quote reftex-citation) "reftex-cite" "\ @@ -10943,6 +10991,8 @@ If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. +FORAT-KEY can be used to pre-select a citation format. + When called with one or two `C-u' prefixes, first rescans the document. When called with a numeric prefix, make that many citations. When called with point inside the braces of a `cite' command, it will @@ -10955,6 +11005,37 @@ ;;;*** +;;;### (autoloads (reftex-index-phrases-mode) "reftex-index" "textmodes/reftex-index.el" +;;;;;; (14425 19352)) +;;; Generated autoloads from textmodes/reftex-index.el + +(autoload (quote reftex-index-phrases-mode) "reftex-index" "\ +Major mode for managing the Index phrases of a LaTeX document. +This buffer was created with RefTeX. + +To insert new phrases, use + - `C-c \\' in the LaTeX document to copy selection or word + - `\\[reftex-index-new-phrase]' in the phrases buffer. + +To index phrases use one of: + +\\[reftex-index-this-phrase] index current phrase +\\[reftex-index-next-phrase] index next phrase (or N with prefix arg) +\\[reftex-index-all-phrases] index all phrases +\\[reftex-index-remaining-phrases] index current and following phrases +\\[reftex-index-region-phrases] index the phrases in the region + +You can sort the phrases in this buffer with \\[reftex-index-sort-phrases]. +To display information about the phrase at point, use \\[reftex-index-phrases-info]. + +For more information see the RefTeX User Manual. + +Here are all local bindings. + +\\{reftex-index-phrases-map}" t nil) + +;;;*** + ;;;### (autoloads (regexp-opt-depth regexp-opt) "regexp-opt" "emacs-lisp/regexp-opt.el" ;;;;;; (14334 30885)) ;;; Generated autoloads from emacs-lisp/regexp-opt.el @@ -11850,7 +11931,7 @@ ;;;*** ;;;### (autoloads (sh-mode) "sh-script" "progmodes/sh-script.el" -;;;;;; (14419 41150)) +;;;;;; (14424 59273)) ;;; Generated autoloads from progmodes/sh-script.el (put (quote sh-mode) (quote mode-class) (quote special)) @@ -13359,7 +13440,7 @@ ;;;### (autoloads (thai-composition-function thai-post-read-conversion ;;;;;; thai-compose-buffer thai-compose-string thai-compose-region ;;;;;; setup-thai-environment) "thai-util" "language/thai-util.el" -;;;;;; (14422 54141)) +;;;;;; (14423 51008)) ;;; Generated autoloads from language/thai-util.el (autoload (quote setup-thai-environment) "thai-util" "\ @@ -13422,7 +13503,7 @@ ;;;;;; tibetan-compose-buffer tibetan-decompose-buffer tibetan-composition-function ;;;;;; tibetan-compose-region tibetan-compose-string tibetan-transcription-to-tibetan ;;;;;; tibetan-tibetan-to-transcription tibetan-char-p setup-tibetan-environment) -;;;;;; "tibet-util" "language/tibet-util.el" (14422 54141)) +;;;;;; "tibet-util" "language/tibet-util.el" (14423 51008)) ;;; Generated autoloads from language/tibet-util.el (autoload (quote setup-tibetan-environment) "tibet-util" nil t nil) diff -r 6bdad766098e -r f281dfbf8cd2 lisp/progmodes/cwarn.el --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lisp/progmodes/cwarn.el Tue Dec 21 09:08:41 1999 +0000 @@ -0,0 +1,483 @@ +;;; cwarn.el --- Highlight suspicious C and C++ constructions. + +;; Copyright (C) 1999 Free Software Foundation, Inc. + +;; Author: Anders Lindgren +;; Keywords: c, languages, faces +;; X-Url: http://www.andersl.com/emacs +;; Version: 1.3.1 1999-12-13 + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;;{{{ Documentation + +;; Description: +;; +;; CWarn is a package that highlights suspicious C and C++ constructions. +;; +;; For example, take a look at the following piece of C code: +;; +;; if (x = 0); +;; foo(); +;; +;; The code contains two, possibly fatal, bugs. The first is that the +;; assignment operator "=" is used as part of the test; the user +;; probably ment to use the comparison operator "==". +;; +;; The second problem is that an extra semicolon is placed after +;; closing parenthesis of the test expression. This makes the body of +;; the if statement to be an empty statement, not the call to the +;; function "foo", as the user probably intended. +;; +;; This package is capable of highlighting the following C and C++ +;; constructions: +;; +;; * Assignments inside expressions, including variations like "+=". +;; * Semicolon following immediately after `if', `for', and `while' +;; (except, of course, after a `do .. while' statement). +;; * C++ functions with reference parameters. +;; +;; Note that none of the constructions highlighted (especially not C++ +;; reference parameters) are considered errors by the langauage +;; definitions. + +;; Usage: +;; +;; CWarn is implemented as two minor modes: `cwarn-mode' and +;; `global-cwarn-mode'. The former can be applied to individual buffers +;; and the latter to all buffers. +;; +;; Activate this package by Customize, or by placing the following line +;; into the appropriate init file: +;; +;; (global-cwarn-mode 1) +;; +;; Also, `font-lock-mode' or `global-font-lock-mode' must be enabled. + +;; Afterthought: +;; +;; After using this package for several weeks it feels as though I +;; find stupid typo-style bugs while editing rather than at compile- +;; or run-time, if I ever find them. +;; +;; On the other hand, I find myself using assignments inside +;; expressions much more often than I used to do. The reason is that +;; there is no risk of interpreting an assignment operator as a +;; comparison ("hey, the assignment operator is red, duh!"). + +;; Reporting bugs: +;; +;; Out of the last ten bugs you found, how many did you report? +;; +;; When reporting a bug, please: +;; +;; * Send a mail the maintainer of the package, or to the author +;; if no maintainer exists. +;; * Include the name of the package in the title of the mail, to +;; simplify for the recipient. +;; * State exactly what you did, what happened, and what you expected +;; to see when you found the bug. +;; * If the bug cause an error, set the variable `debug-on-error' to t, +;; repreat the operations that triggered the error and include +;; the backtrace in the letter. +;; * If possible, include an example that activates the bug. +;; * Should you speculate about the cause of the problem, please +;; state explicitly that you are guessing. + +;;}}} + +;;; Code: + +;;{{{ Dependencies + +(eval-when-compile (require 'cl)) + +(require 'custom) +(require 'font-lock) +(require 'cc-mode) + +;;}}} +;;{{{ Variables + +(defgroup cwarn nil + "Highlight suspicious C and C++ constructions." + :group 'faces) + +(defvar cwarn-mode nil + "*Non-nil when Cwarn mode is active. + +Never set this variable directly, use the command `cwarn-mode' +instead.") + +(defcustom global-cwarn-mode nil + "*When on, suspicious C and C++ constructions are highlighted. + +Set this variable using \\[customize] or use the command +`global-cwarn-mode'." + :group 'cwarn + :initialize 'custom-initialize-default + :set '(lambda (symbol value) + (global-cwarn-mode (or value 0))) + :type 'boolean + :require 'cwarn) + +(defcustom cwarn-configuration + '((c-mode (not reference)) + (c++-mode t)) + "*List of items each describing which features are enable for a mode. +Each item is on the form (mode featurelist), where featurelist can be +on one of three forms: + +* A list of enabled features. +* A list starting with the atom `not' followed by the features + which are not enabled. +* The atom t, that represent that all features are enabled. + +See variable `cwarn-font-lock-feature-keywords-alist' for available +features." + :group 'cwarn) + +(defcustom cwarn-font-lock-feature-keywords-alist + '((assign . cwarn-font-lock-assignment-keywords) + (semicolon . cwarn-font-lock-semicolon-keywords) + (reference . cwarn-font-lock-reference-keywords)) + "*Maps a CWarn feature to font-lock keywords. +The keywords could either a font-lock keyword list or a symbol. +If it is a symbol it is assumed to be a variable containing a font-lock +keyword list." + :group 'cwarn) + +(defcustom cwarn-verbose t + "*When nil, CWarn mode will not generate any messages. + +Currently, messages are generated when the mode is activated and +deactivated." + :group 'cwarn + :type 'boolean) + +(defcustom cwarn-mode-text " CWarn" + "*String to display in the mode line when CWarn mode is active. + +\(When the string is not empty, make sure that it has a leading space.)" + :tag "CWarn mode text" ; To separate it from `global-...' + :group 'cwarn + :type 'string) + +(defcustom cwarn-mode-hook nil + "*Functions to run when CWarn mode is activated." + :tag "CWarn mode hook" ; To separate it from `global-...' + :group 'cwarn + :type 'hook) + +(defcustom global-cwarn-mode-text "" + "*String to display when Global CWarn mode is active. + +The default is nothing since when this mode is active this text doesn't +vary over time, or between buffers. Hence mode line text +would only waste precious space." + :group 'cwarn + :type 'string) + +(defcustom global-cwarn-mode-hook nil + "*Hook called when Global CWarn mode is activated." + :group 'cwarn + :type 'hook) + +(defcustom cwarn-load-hook nil + "*Functions to run when CWarn mode is first loaded." + :tag "Load Hook" + :group 'cwarn + :type 'hook) + +;;}}} +;;{{{ The modes + +;;;###autoload +(defun cwarn-mode (&optional arg) + "Minor mode that hightlight suspicious C and C++ constructions. + +Note, in addition to enabling this minor mode, the major mode must +be included in the variable `cwarn-configuration'. By default C and +C++ modes are included. + +With ARG, turn CWarn mode on if and only if arg is positive." + (interactive "P") + (make-local-variable 'cwarn-mode) + (setq cwarn-mode + (if (null arg) + (not cwarn-mode) + (> (prefix-numeric-value arg) 0))) + (if (and cwarn-verbose + (interactive-p)) + (message "Cwarn mode is now %s." + (if cwarn-mode "on" "off"))) + (if (not global-cwarn-mode) + (if cwarn-mode + (cwarn-font-lock-add-keywords) + (cwarn-font-lock-remove-keywords))) + (font-lock-fontify-buffer) + (if cwarn-mode + (run-hooks 'cwarn-mode-hook))) + +;;;###autoload +(defun turn-on-cwarn-mode () + "Turn on CWarn mode. + +This function is designed to be added to hooks, for example: + (add-hook 'c-mode-hook 'turn-on-cwarn-mode)" + (cwarn-mode 1)) + +;;;###autoload +(defun global-cwarn-mode (&optional arg) + "Hightlight suspicious C and C++ constructions in all buffers. + +With ARG, turn CWarn mode on globally if and only if arg is positive." + (interactive "P") + (let ((old-global-cwarn-mode global-cwarn-mode)) + (setq global-cwarn-mode + (if (null arg) + (not global-cwarn-mode) + (> (prefix-numeric-value arg) 0))) + (if (and cwarn-verbose + (interactive-p)) + (message "Global CWarn mode is now %s." + (if global-cwarn-mode "on" "off"))) + (when (not (eq global-cwarn-mode old-global-cwarn-mode)) + ;; Update for all future buffers. + (dolist (conf cwarn-configuration) + (if global-cwarn-mode + (cwarn-font-lock-add-keywords (car conf)) + (cwarn-font-lock-remove-keywords (car conf)))) + ;; Update all existing buffers. + (save-excursion + (dolist (buffer (buffer-list)) + (set-buffer buffer) + ;; Update keywords in alive buffers. + (when (and font-lock-mode + (not cwarn-mode) + (cwarn-is-enabled major-mode)) + (if global-cwarn-mode + (cwarn-font-lock-add-keywords) + (cwarn-font-lock-remove-keywords)) + (font-lock-fontify-buffer)))))) + ;; Kills all added keywords :-( + ;; (font-lock-mode 0) + ;; (makunbound 'font-lock-keywords) + ;; (font-lock-mode 1)))) + (when global-cwarn-mode + (run-hooks 'global-cwarn-mode-hook))) + +;;}}} +;;{{{ Help functions + +(defun cwarn-is-enabled (mode &optional feature) + "Non-nil if CWarn FEATURE is enabled for MODE. +feature is an atom representing one construction to highlight. + +Check if any feature is enabled for MODE if no feature is specified. + +The valid features are described by the variable +`cwarn-font-lock-feature-keywords-alist'." + (let ((mode-configuraion (assq mode cwarn-configuration))) + (and mode-configuraion + (or (null feature) + (let ((list-or-t (nth 1 mode-configuraion))) + (or (eq list-or-t t) + (if (eq (car-safe list-or-t) 'not) + (not (memq feature (cdr list-or-t))) + (memq feature list-or-t)))))))) + +(defun cwarn-inside-macro () + "True if point is inside a C macro definition." + (save-excursion + (beginning-of-line) + (while (eq (char-before (1- (point))) ?\\) + (forward-line -1)) + (back-to-indentation) + (eq (char-after) ?#))) + +(defun cwarn-font-lock-add-keywords (&optional mode) + "Install keywords into major MODE, or into current buffer if nil." + (dolist (pair cwarn-font-lock-feature-keywords-alist) + (let ((feature (car pair)) + (keywords (cdr pair))) + (if (not (listp keywords)) + (setq keywords (symbol-value keywords))) + (if (cwarn-is-enabled (or mode major-mode) feature) + (font-lock-add-keywords mode keywords))))) + +(defun cwarn-font-lock-remove-keywords (&optional mode) + "Remove keywords from major MODE, or from current buffer if nil." + (dolist (pair cwarn-font-lock-feature-keywords-alist) + (let ((feature (car pair)) + (keywords (cdr pair))) + (if (not (listp keywords)) + (setq keywords (symbol-value keywords))) + (if (cwarn-is-enabled (or mode major-mode) feature) + (font-lock-remove-keywords mode keywords))))) + +;;}}} +;;{{{ Backward compatibility + +;; This piece of code will be part of CC mode as of Emacs 20.4. +(if (not (fboundp 'c-at-toplevel-p)) +(defun c-at-toplevel-p () + "Return a determination as to whether point is at the `top-level'. +Being at the top-level means that point is either outside any +enclosing block (such function definition), or inside a class +definition, but outside any method blocks. + +If point is not at the top-level (e.g. it is inside a method +definition), then nil is returned. Otherwise, if point is at a +top-level not enclosed within a class definition, t is returned. +Otherwise, a 2-vector is returned where the zeroth element is the +buffer position of the start of the class declaration, and the first +element is the buffer position of the enclosing class's opening +brace." + (let ((state (c-parse-state))) + (or (not (c-most-enclosing-brace state)) + (c-search-uplist-for-classkey state)))) +) + +;;}}} +;;{{{ Font-lock keywords and match functions + +;; This section contains font-lock keywords. A font lock keyword can +;; either contain a regular expression or a match function. All +;; keywords defined here use match functions since the C and C++ +;; constructions highlighted by CWarn are too complex to be matched by +;; regular expressions. +;; +;; A match function should act like a normal forward search. They +;; should return non-nil if they found a candidate and the match data +;; should correspond to the highlight part of the font-lock keyword. +;; The functions shold not generate errors, in that case font-lock +;; will fail to highlight the buffer. A match function takes one +;; argument, LIMIT, that represent the end of area to be searched. +;; +;; The variable `cwarn-font-lock-feature-keywords-alist' contains a +;; mapping from CWarn features to the font-lock keywords defined +;; below. + +;;{{{ Assignment in expressions + +(defconst cwarn-font-lock-assignment-keywords + '((cwarn-font-lock-match-assignment-in-expression + (1 font-lock-warning-face)))) + +(defun cwarn-font-lock-match-assignment-in-expression (limit) + "Match assignments inside expressions." + (let ((res nil)) + (while + (progn + (setq res (re-search-forward "[^!<>=]\\(=\\)[^=]" limit t)) + (and res + (save-excursion + (goto-char (match-beginning 1)) + (condition-case nil ; In case "backward-up-list" barfs. + (progn + (backward-up-list 1) + (or (not (memq (following-char) '(?\( ?\[))) + (save-match-data + (skip-chars-backward " ") + (skip-chars-backward "a-zA-Z0-9_") + (or + ;; Default parameter of function. + (c-at-toplevel-p) + (looking-at "for\\>"))))) + (error t)))))) + res)) + +;;}}} +;;{{{ Semicolon + +(defconst cwarn-font-lock-semicolon-keywords + '((cwarn-font-lock-match-dangerous-semicolon (0 font-lock-warning-face)))) + +(defun cwarn-font-lock-match-dangerous-semicolon (limit) + "Match semicolons directly after `for', `while', and `if'. +Tne semicolon after a `do { ... } while (x);' construction is not matched." + (let ((res nil)) + (while + (progn + (setq res (search-forward ";" limit t)) + (and res + (save-excursion + (condition-case nil ; In case something barfs. + (save-match-data + (backward-sexp 2) ; Expression and keyword. + (not (or (looking-at "\\(for\\|if\\)\\>") + (and (looking-at "while\\>") + (condition-case nil + (progn + (backward-sexp 2) ; Body and "do". + (not (looking-at "do\\>"))) + (error t)))))) + (error t)))))) + res)) + +;;}}} +;;{{{ Reference + +(defconst cwarn-font-lock-reference-keywords + '((cwarn-font-lock-match-reference (1 font-lock-warning-face)))) + +(defun cwarn-font-lock-match-reference (limit) + "Font-lock matcher for C++ reference parameters." + (let ((res nil)) + (while + (progn + (setq res (re-search-forward "[^&]\\(&\\)[^&=]" limit t)) + (and res + (save-excursion + (goto-char (match-beginning 1)) + (condition-case nil ; In case something barfs. + (save-match-data + (backward-up-list 1) + (or (not (eq (following-char) ?\()) + (cwarn-inside-macro) + (not (c-at-toplevel-p)))) + (error t)))))) + res)) + +;;}}} + +;;}}} +;;{{{ The end + +(unless (assq 'cwarn-mode minor-mode-alist) + (push '(cwarn-mode cwarn-mode-text) + minor-mode-alist)) +(unless (assq 'global-cwarn-mode minor-mode-alist) + (push '(global-cwarn-mode global-cwarn-mode-text) + minor-mode-alist)) + +(provide 'cwarn) + +(run-hooks 'cwarn-load-hook) + +;; This makes it possible to set Global CWarn mode from +;; Customize. +(if global-cwarn-mode + (global-cwarn-mode 1)) + +;;}}} + +;;; cwarn.el ends here