help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Get rid of free variable warning from other packages?


From: Drew Adams
Subject: RE: Get rid of free variable warning from other packages?
Date: Tue, 9 Apr 2013 15:13:33 -0700

> In my package, I setq some variables that are defined in other
> packages. (Specifically, in ido-vertical-mode, I setq
> ido-decorations.) Is there a way to disable the warning that
> says I'm setqing a free variable?

(defvar ido-decorations)

IOW, a vacuous defvar: no value initialization.

> Or better yet, is there a better way to set a variable that
> belongs to another package, only when my minor-mode is
> enabled, and have it reverted back when my minor-mode is
> disabled?

A different topic (not "or better yet").

When your minor mode is turned on, save the current value of the other-package
variable in your own separate, internal variable.  When your mode is turned off,
restore the saved value.

This is not perfect, of course, since presumably other interactions while your
mode is active might change that package variable's value, so restoring (when
you exit your mode) the value it had when your mode was turned on might not be
the right thing to do.  It's a judgment call based on your particular context.

(OT - For key bindings, things are typically simpler: you can just define
bindings in your minor-mode map that shadow bindings in major modes (and in
other minor modes, if you can finagle things so yours come out on top).)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]