* Get rid of free variable warning from other packages?
@ 2013-04-09 19:30 Steven Degutis
2013-04-09 19:35 ` Bob Proulx
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Steven Degutis @ 2013-04-09 19:30 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
[-- Attachment #1: Type: text/plain, Size: 404 bytes --]
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?
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?
-Steven
[-- Attachment #2: Type: text/html, Size: 494 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Get rid of free variable warning from other packages?
2013-04-09 19:30 Get rid of free variable warning from other packages? Steven Degutis
@ 2013-04-09 19:35 ` Bob Proulx
2013-04-09 22:13 ` Drew Adams
2013-04-10 7:38 ` Kevin Rodgers
2 siblings, 0 replies; 9+ messages in thread
From: Bob Proulx @ 2013-04-09 19:35 UTC (permalink / raw)
To: help-gnu-emacs
Steven Degutis wrote:
> ... Is there a way to disable the warning that says I'm setqing a
> free variable?
Search for use of "eval-after-load" and you will find much discussion.
For example I routinely do things like this:
(eval-after-load 'text-mode
(add-hook 'text-mode-hook
(lambda ()
(abbrev-mode 1)
(auto-fill-mode 1))))
I think you should be able to map that example into something useful
for your mode case.
> 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?
Most configuration variables are already buffer local.
http://emacswiki.org/emacs/BufferLocalVariable
http://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Buffer_002dLocal.html
Bob
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Get rid of free variable warning from other packages?
2013-04-09 19:30 Get rid of free variable warning from other packages? Steven Degutis
2013-04-09 19:35 ` Bob Proulx
@ 2013-04-09 22:13 ` Drew Adams
2013-04-09 22:22 ` Steven Degutis
2013-04-10 5:31 ` Andreas Röhler
2013-04-10 7:38 ` Kevin Rodgers
2 siblings, 2 replies; 9+ messages in thread
From: Drew Adams @ 2013-04-09 22:13 UTC (permalink / raw)
To: 'Steven Degutis', help-gnu-emacs
> 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).)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Get rid of free variable warning from other packages?
2013-04-09 22:13 ` Drew Adams
@ 2013-04-09 22:22 ` Steven Degutis
2013-04-10 5:31 ` Andreas Röhler
1 sibling, 0 replies; 9+ messages in thread
From: Steven Degutis @ 2013-04-09 22:22 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]
Thanks. That's actually what I currently do:
https://github.com/sdegutis/ido-vertical-mode.el/blob/master/ido-vertical-mode.el#L138-L165
The plugin in question: https://github.com/sdegutis/ido-vertical-mode.el
-Steven
On Tue, Apr 9, 2013 at 5:13 PM, Drew Adams <drew.adams@oracle.com> wrote:
> > 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).)
>
>
[-- Attachment #2: Type: text/html, Size: 2331 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Get rid of free variable warning from other packages?
2013-04-09 22:13 ` Drew Adams
2013-04-09 22:22 ` Steven Degutis
@ 2013-04-10 5:31 ` Andreas Röhler
2013-04-10 13:46 ` Drew Adams
1 sibling, 1 reply; 9+ messages in thread
From: Andreas Röhler @ 2013-04-10 5:31 UTC (permalink / raw)
To: help-gnu-emacs
Am 10.04.2013 00:13, schrieb Drew Adams:
[ ... ]
> (defvar ido-decorations)
>
> IOW, a vacuous defvar: no value initialization.
>
In Emacs Lisp, the symbol nil has two meanings. First, it means the empty list. Second, it means false and is the value returned when a true-or-false-test tests false.
http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/nil-explained.html
Or to say: nil means false, but false is more than nothing :)
Cheers,
Andreas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Get rid of free variable warning from other packages?
2013-04-09 19:30 Get rid of free variable warning from other packages? Steven Degutis
2013-04-09 19:35 ` Bob Proulx
2013-04-09 22:13 ` Drew Adams
@ 2013-04-10 7:38 ` Kevin Rodgers
2013-04-10 13:55 ` Stefan Monnier
2 siblings, 1 reply; 9+ messages in thread
From: Kevin Rodgers @ 2013-04-10 7:38 UTC (permalink / raw)
To: help-gnu-emacs
On 4/9/13 1:30 PM, Steven Degutis wrote:
> 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?
(require 'foo) at the top level, where `foo' is the package that defines the
variables you want to set.
> 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?
When the minor mode is enabled: (set (make-local-variable 'foo-bar) local-value)
When the minor mode is disabled: (setq foo-bar (default-value 'foo-bar))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: Get rid of free variable warning from other packages?
2013-04-10 5:31 ` Andreas Röhler
@ 2013-04-10 13:46 ` Drew Adams
0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2013-04-10 13:46 UTC (permalink / raw)
To: 'Andreas Röhler', help-gnu-emacs
> > (defvar ido-decorations)
> > IOW, a vacuous defvar: no value initialization.
>
> In Emacs Lisp, the symbol nil has two meanings. First, it
> means the empty list. Second, it means false and is the value
> returned when a true-or-false-test tests false.
>
http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/nil-explained.html
> Or to say: nil means false, but false is more than nothing :)
What's the relation to the text you quoted?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Get rid of free variable warning from other packages?
2013-04-10 7:38 ` Kevin Rodgers
@ 2013-04-10 13:55 ` Stefan Monnier
2013-04-15 2:37 ` Kevin Rodgers
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2013-04-10 13:55 UTC (permalink / raw)
To: help-gnu-emacs
> When the minor mode is disabled: (setq foo-bar (default-value 'foo-bar))
Did you mean (kill-local-variable 'foo-bar)?
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Get rid of free variable warning from other packages?
2013-04-10 13:55 ` Stefan Monnier
@ 2013-04-15 2:37 ` Kevin Rodgers
0 siblings, 0 replies; 9+ messages in thread
From: Kevin Rodgers @ 2013-04-15 2:37 UTC (permalink / raw)
To: help-gnu-emacs
On 4/10/13 7:55 AM, Stefan Monnier wrote:
>> When the minor mode is disabled: (setq foo-bar (default-value 'foo-bar))
>
> Did you mean (kill-local-variable 'foo-bar)?
Still learning :-)
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-04-15 2:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-09 19:30 Get rid of free variable warning from other packages? Steven Degutis
2013-04-09 19:35 ` Bob Proulx
2013-04-09 22:13 ` Drew Adams
2013-04-09 22:22 ` Steven Degutis
2013-04-10 5:31 ` Andreas Röhler
2013-04-10 13:46 ` Drew Adams
2013-04-10 7:38 ` Kevin Rodgers
2013-04-10 13:55 ` Stefan Monnier
2013-04-15 2:37 ` Kevin Rodgers
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.