Subject: bug#16290: 23.4; csharp-mode advice to revert-buffer causes error when flymake-mode not loaded

From: [email-masked] (Robert P. Goldman)
Date: Sun, 29 Dec 2013 15:40:30 -0600

The following advice is in csharp-mode:

(defadvice revert-buffer (around
                          csharp-advise-revert-buffer
                          activate compile)
  (let ((is-flymake-enabled
         (and (fboundp 'flymake-mode)
              flymake-mode)))
    ;; disable
    (if is-flymake-enabled
        (flymake-mode-off))

    ;; revert
    ad-do-it

    ;; enable
    (if is-flymake-enabled
        (flymake-mode-on))))

This assumes that (fboundp 'flymake-mode) implies that the variable
flymake-mode exists.

This assumption is incorrect.  (fboundp 'flymake-mode) will return true
if there is an autoload for flymake-mode, but that autoload has not been
forced yet.  Then a reference to the flymake-mode variable will cause an
error condition.

In GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-09-08 on trouble, modified by Debian
configured using `configure  '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.4/site-lisp:/usr/share/emacs/site-lisp' '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -DDEBIAN -O2' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  recentf-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
i n d - f TAB u TAB RET RET C-x b RET ESC x a d - r 
e TAB m v TAB DEL o TAB RET r e v e r TAB RET q C-x 
b M i TAB RET ESC x r e v e r t - b u TAB RET d q C-x 
b f l TAB RET C-x 1 C-h v f l y TAB C-g ESC < C-s m 
a k e - m i n o r - C-a C-s m i n o r - m o d e C-a 
C-e C-a ESC f ESC h C-x o C-h f RET C-x o C-a C-x o 
C-a ESC 2 C-@ C-g C-x 1 C-d e f i n e - m i n o r C-r 
C-r ESC < C-s d e f i n e - m C-a C-@ ESC C-f ESC x 
m a c TAB r TAB DEL DEL DEL DEL e l i TAB C-g ESC w 
C-x b * s c TAB RET C-e C-n C-n RET ( m a c r o e x 
p a n d SPC ' C-y ) RET C-p C-e C-x C-e ESC x e v a 
l - p r TAB RET C-p C-p C-p C-p C-p C-p ESC : f l y 
m a k e - m o d e RET q C-x b f TAB l y TAB C-g ESC 
> ( f u n DEL DEL DEL s u y m DEL DEL DEL y m b o l 
- f u n ESC TAB SPC ' f l y m a k e - m o d e ) C-x 
C-e ESC x r e p o r t - e m TAB RET

Recent messages:
Mark set
(progn (progn (defvar flymake-mode nil "Non-nil if Flymake mode is enabled.
Use the command `flymake-mode' to change this variable.") (make-variable-buffer-local (quote flymake-mode))) (defun flymake-mode (&optional arg) "Minor mode to do on-the-fly syntax checking.
When called interactively, toggles the minor mode.
With arg, turn Flymake mode on if and only if arg is positive." (interactive (list ...)) (let (...) (setq flymake-mode ...) (cond ... ...) (run-hooks ... ...) (if ... ...)) (force-mode-line-update) flymake-mode) :autoload-end nil (add-minor-mode (quote flymake-mode) (quote flymake-mode-line) (if (boundp ...) flymake-mode-map)))
Entering debugger...
Back to top level.
Making completion list...
Quit
Mark set
(autoload "flymake" 1040217 t nil)

Load-path shadows:
/usr/share/emacs23/site-lisp/prolog-el/prolog hides /usr/share/emacs/site-lisp/prolog-el/prolog
/home/rpg/emacs-packages/org-mode/contrib/lisp/htmlize hides /usr/share/emacs23/site-lisp/emacs-goodies-el/htmlize
/usr/share/emacs23/site-lisp/css-mode/css-mode hides /usr/share/emacs/site-lisp/css-mode/css-mode
/usr/share/emacs/23.4/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs/23.4/site-lisp/crypt++ hides /usr/share/emacs/site-lisp/crypt++
/usr/share/emacs/23.4/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs23/site-lisp/html-helper-mode/tempo hides /usr/share/emacs/23.4/lisp/tempo
/usr/share/emacs23/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/23.4/lisp/textmodes/flyspell
/usr/share/emacs23/site-lisp/css-mode/css-mode hides /usr/share/emacs/23.4/lisp/textmodes/css-mode
/usr/share/emacs23/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/23.4/lisp/textmodes/ispell
/usr/share/emacs23/site-lisp/prolog-el/prolog hides /usr/share/emacs/23.4/lisp/progmodes/prolog
/home/rpg/emacs-packages/org-mode/lisp/org-datetree hides /usr/share/emacs/23.4/lisp/org/org-datetree
/home/rpg/emacs-packages/org-mode/lisp/org-indent hides /usr/share/emacs/23.4/lisp/org/org-indent
/home/rpg/emacs-packages/org-mode/contrib/lisp/org-wl hides /usr/share/emacs/23.4/lisp/org/org-wl
/home/rpg/emacs-packages/org-mode/lisp/org-habit hides /usr/share/emacs/23.4/lisp/org/org-habit
/home/rpg/emacs-packages/org-mode/lisp/org-agenda hides /usr/share/emacs/23.4/lisp/org/org-agenda
/home/rpg/emacs-packages/org-mode/lisp/org-mouse hides /usr/share/emacs/23.4/lisp/org/org-mouse
/home/rpg/emacs-packages/org-mode/lisp/org-plot hides /usr/share/emacs/23.4/lisp/org/org-plot
/home/rpg/emacs-packages/org-mode/lisp/org-bibtex hides /usr/share/emacs/23.4/lisp/org/org-bibtex
/home/rpg/emacs-packages/org-mode/lisp/org-faces hides /usr/share/emacs/23.4/lisp/org/org-faces
/home/rpg/emacs-packages/org-mode/lisp/org-install hides /usr/share/emacs/23.4/lisp/org/org-install
/home/rpg/emacs-packages/org-mode/contrib/lisp/org-mew hides /usr/share/emacs/23.4/lisp/org/org-mew
/home/rpg/emacs-packages/org-mode/lisp/org-rmail hides /usr/share/emacs/23.4/lisp/org/org-rmail
/home/rpg/emacs-packages/org-mode/lisp/org-src hides /usr/share/emacs/23.4/lisp/org/org-src
/home/rpg/emacs-packages/org-mode/lisp/org-mobile hides /usr/share/emacs/23.4/lisp/org/org-mobile
/home/rpg/emacs-packages/org-mode/contrib/lisp/org-vm hides /usr/share/emacs/23.4/lisp/org/org-vm
/home/rpg/emacs-packages/org-mode/lisp/org-attach hides /usr/share/emacs/23.4/lisp/org/org-attach
/home/rpg/emacs-packages/org-mode/lisp/org-archive hides /usr/share/emacs/23.4/lisp/org/org-archive
/home/rpg/emacs-packages/org-mode/lisp/org-protocol hides /usr/share/emacs/23.4/lisp/org/org-protocol
/home/rpg/emacs-packages/org-mode/lisp/org-clock hides /usr/share/emacs/23.4/lisp/org/org-clock
/home/rpg/emacs-packages/org-mode/lisp/org-info hides /usr/share/emacs/23.4/lisp/org/org-info
/home/rpg/emacs-packages/org-mode/lisp/org-colview hides /usr/share/emacs/23.4/lisp/org/org-colview
/home/rpg/emacs-packages/org-mode/lisp/org-irc hides /usr/share/emacs/23.4/lisp/org/org-irc
/home/rpg/emacs-packages/org-mode/lisp/org-footnote hides /usr/share/emacs/23.4/lisp/org/org-footnote
/home/rpg/emacs-packages/org-mode/lisp/org-w3m hides /usr/share/emacs/23.4/lisp/org/org-w3m
/home/rpg/emacs-packages/org-mode/lisp/org-compat hides /usr/share/emacs/23.4/lisp/org/org-compat
/home/rpg/emacs-packages/org-mode/lisp/org-table hides /usr/share/emacs/23.4/lisp/org/org-table
/home/rpg/emacs-packages/org-mode/lisp/org hides /usr/share/emacs/23.4/lisp/org/org
/home/rpg/emacs-packages/org-mode/lisp/org-feed hides /usr/share/emacs/23.4/lisp/org/org-feed
/home/rpg/emacs-packages/org-mode/lisp/org-bbdb hides /usr/share/emacs/23.4/lisp/org/org-bbdb
/home/rpg/emacs-packages/org-mode/lisp/org-macs hides /usr/share/emacs/23.4/lisp/org/org-macs
/home/rpg/emacs-packages/org-mode/lisp/org-gnus hides /usr/share/emacs/23.4/lisp/org/org-gnus
/home/rpg/emacs-packages/org-mode/lisp/org-timer hides /usr/share/emacs/23.4/lisp/org/org-timer
/home/rpg/emacs-packages/org-mode/lisp/org-list hides /usr/share/emacs/23.4/lisp/org/org-list
/home/rpg/emacs-packages/org-mode/lisp/org-inlinetask hides /usr/share/emacs/23.4/lisp/org/org-inlinetask
/home/rpg/emacs-packages/org-mode/lisp/org-crypt hides /usr/share/emacs/23.4/lisp/org/org-crypt
/home/rpg/emacs-packages/org-mode/lisp/org-id hides /usr/share/emacs/23.4/lisp/org/org-id
/home/rpg/emacs-packages/org-mode/lisp/org-mhe hides /usr/share/emacs/23.4/lisp/org/org-mhe
/usr/share/emacs23/site-lisp/auctex/preview hides /usr/share/emacs/site-lisp/auctex/preview
/usr/share/emacs23/site-lisp/auctex/tex-mik hides /usr/share/emacs/site-lisp/auctex/tex-mik
/usr/share/emacs23/site-lisp/auctex/bib-cite hides /usr/share/emacs/site-lisp/auctex/bib-cite
/usr/share/emacs23/site-lisp/auctex/font-latex hides /usr/share/emacs/site-lisp/auctex/font-latex
/usr/share/emacs23/site-lisp/auctex/tex-font hides /usr/share/emacs/site-lisp/auctex/tex-font
/usr/share/emacs23/site-lisp/auctex/texmathp hides /usr/share/emacs/site-lisp/auctex/texmathp
/usr/share/emacs23/site-lisp/auctex/toolbar-x hides /usr/share/emacs/site-lisp/auctex/toolbar-x
/usr/share/emacs23/site-lisp/auctex/context hides /usr/share/emacs/site-lisp/auctex/context
/usr/share/emacs23/site-lisp/auctex/tex-fptex hides /usr/share/emacs/site-lisp/auctex/tex-fptex
/usr/share/emacs23/site-lisp/auctex/prv-emacs hides /usr/share/emacs/site-lisp/auctex/prv-emacs
/usr/share/emacs23/site-lisp/auctex/tex-buf hides /usr/share/emacs/site-lisp/auctex/tex-buf
/usr/share/emacs23/site-lisp/auctex/context-nl hides /usr/share/emacs/site-lisp/auctex/context-nl
/usr/share/emacs23/site-lisp/auctex/multi-prompt hides /usr/share/emacs/site-lisp/auctex/multi-prompt
/usr/share/emacs23/site-lisp/auctex/tex-style hides /usr/share/emacs/site-lisp/auctex/tex-style
/usr/share/emacs23/site-lisp/auctex/tex hides /usr/share/emacs/site-lisp/auctex/tex
/usr/share/emacs23/site-lisp/auctex/tex-info hides /usr/share/emacs/site-lisp/auctex/tex-info
/usr/share/emacs23/site-lisp/auctex/latex hides /usr/share/emacs/site-lisp/auctex/latex
/usr/share/emacs23/site-lisp/auctex/tex-fold hides /usr/share/emacs/site-lisp/auctex/tex-fold
/usr/share/emacs23/site-lisp/auctex/tex-jp hides /usr/share/emacs/site-lisp/auctex/tex-jp
/usr/share/emacs23/site-lisp/auctex/context-en hides /usr/share/emacs/site-lisp/auctex/context-en
/usr/share/emacs23/site-lisp/auctex/tex-bar hides /usr/share/emacs/site-lisp/auctex/tex-bar
/usr/share/emacs23/site-lisp/html-helper-mode/html-helper-mode hides /usr/share/emacs/site-lisp/html-helper-mode/html-helper-mode
/usr/share/emacs23/site-lisp/html-helper-mode/visual-basic-mode hides /usr/share/emacs/site-lisp/html-helper-mode/visual-basic-mode
/usr/share/emacs23/site-lisp/html-helper-mode/tempo hides /usr/share/emacs/site-lisp/html-helper-mode/tempo
/usr/share/emacs23/site-lisp/html-helper-mode/hhm-config hides /usr/share/emacs/site-lisp/html-helper-mode/hhm-config

Features:
(shadow sort mail-extr emacsbug vc-cvs vc-rcs vc-dir ewoc pcmpl-unix
log-edit pcvs-util add-log diff-mode etags cdlatex-autoloads texmathp
parse-time timezone ob-sh ob-perl reftex-vcr reftex-dcr reftex
reftex-vars org-element org-rmail org-mhe org-irc org-info org-gnus
org-docview doc-view image-mode org-bibtex bibtex org-bbdb org-w3m
dired-aux jka-compr debug cus-edit cus-start cus-load dired newcomment
fic-mode ansi-color em-unix em-term term disp-table ehelp electric
em-script em-prompt em-ls em-hist em-pred em-glob em-dirs em-cmpl
em-basic esh-opt em-banner em-alias esh-var esh-io esh-cmd esh-ext
esh-proc esh-arg eldoc esh-groups eshell esh-module esh-mode esh-util
insert-date-stamp stardate string imenu csharp-mode
csharp-mode-autoloads cc-langs cc-mode cc-fonts cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs compile lisp-mnt help-mode
view multi-isearch finder-inf url-http tls url-gw url-auth vc-svn
google-contacts xml url-cache url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-util url-parse url-vars
google-oauth package generic uniquify org-protocol org-depend org
org-macro org-footnote org-pcomplete pcomplete org-list org-faces
org-entities noutline outline org-fixup autoload ob-emacs-lisp ob
ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint
ob-core ob-eval org-compat org-macs find-func cal-menu calendar
cal-loaddefs gnus-sum nnoo gnus-group gnus-undo nnmail mail-source
gnus-start gnus-spec gnus-int gnus-range message sendmail ecomplete
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mailcap mail-parse
rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev gmm-utils mailheader
canlock sha1 hex-util hashcash gnus-win gnus gnus-ems nnheader
mail-utils mm-util mail-prsvr vc vc-dispatcher server completion tempo
slime-indentation slime-tramp tramp-imap assoc tramp-gw tramp-fish
tramp-smb tramp-cache tramp-ftp tramp-cmds tramp auth-source gnus-util
netrc time-date shell password-cache format-spec tramp-compat trampver
slime-asdf warnings slime-fancy slime-fontifying-fu slime-package-fu
slime-references slime-scratch slime-presentations slime-fuzzy
slime-fancy-trace slime-fancy-inspector slime-c-p-c
slime-editing-commands slime-autodoc advice advice-preload slime-parse
slime-repl recentf tree-widget wid-edit slime byte-opt bytecomp
byte-compile regexp-opt derived help-fns easymenu pp comint ring
hyperspec thingatpt browse-url edmacro kmacro cl cl-19 emacs-goodies-el
emacs-goodies-custom emacs-goodies-loaddefs easy-mmode crypt crypt++
crypt+pgp-pub preview-latex tex-site auto-loads tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd
fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces
cus-face files text-properties overlay md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote
make-network-process dbusbind system-font-setting font-render-setting
gtk x-toolkit x multi-tty emacs)