* emacs init and mode-maps
@ 2006-06-22 7:17 Andreas Roehler
2006-06-22 8:58 ` Reiner Steib
0 siblings, 1 reply; 17+ messages in thread
From: Andreas Roehler @ 2006-06-22 7:17 UTC (permalink / raw)
After defining a key in my emacs init file
(define-key sh-mode-map "\M-#" 'variable-anlegen)
emacs refused further loading and I got the following error
"Symbol's value as variable is void: sh-mode-map".
Meanwhile I know, that
(require 'sh-script)
in the init file before will solve the problem.
Nonetheless, I consider this error as not appropriate,
as defining mode-keys in init files is a common task.
Suggest to enhance usability/convenience here.
What about to make all mode-maps autoloaded?
Or to give some advice if encountering that error?
Thanks to all participants!
__
Andreas Roehler
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-22 7:17 emacs init and mode-maps Andreas Roehler
@ 2006-06-22 8:58 ` Reiner Steib
2006-06-22 9:22 ` David Kastrup
0 siblings, 1 reply; 17+ messages in thread
From: Reiner Steib @ 2006-06-22 8:58 UTC (permalink / raw)
On Thu, Jun 22 2006, Andreas Roehler wrote:
> After defining a key in my emacs init file
>
> (define-key sh-mode-map "\M-#" 'variable-anlegen)
>
> emacs refused further loading and I got the following error
>
> "Symbol's value as variable is void: sh-mode-map".
>
> Meanwhile I know, that
> (require 'sh-script)
>
> in the init file before will solve the problem.
>
> Nonetheless, I consider this error as not appropriate,
> as defining mode-keys in init files is a common task.
Use `eval-after-load' or a mode hook.
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-22 8:58 ` Reiner Steib
@ 2006-06-22 9:22 ` David Kastrup
2006-06-22 10:02 ` Reiner Steib
0 siblings, 1 reply; 17+ messages in thread
From: David Kastrup @ 2006-06-22 9:22 UTC (permalink / raw)
Reiner Steib <reinersteib+gmane@imap.cc> writes:
> On Thu, Jun 22 2006, Andreas Roehler wrote:
>
>> After defining a key in my emacs init file
>>
>> (define-key sh-mode-map "\M-#" 'variable-anlegen)
>>
>> emacs refused further loading and I got the following error
>>
>> "Symbol's value as variable is void: sh-mode-map".
>>
>> Meanwhile I know, that
>> (require 'sh-script)
>>
>> in the init file before will solve the problem.
>>
>> Nonetheless, I consider this error as not appropriate,
>> as defining mode-keys in init files is a common task.
>
> Use `eval-after-load' or a mode hook.
(add-hook 'sh-mode-hook (lambda nil
(define-key sh-mode-map "\M-#" 'variable-anlegen)))
Would be sort of the usual way to do this. eval-after-load is rather
an emergency measure and not desirable here.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-22 9:22 ` David Kastrup
@ 2006-06-22 10:02 ` Reiner Steib
2006-06-22 13:58 ` Andreas Roehler
0 siblings, 1 reply; 17+ messages in thread
From: Reiner Steib @ 2006-06-22 10:02 UTC (permalink / raw)
On Thu, Jun 22 2006, David Kastrup wrote:
> Reiner Steib <reinersteib+gmane@imap.cc> writes:
>> Use `eval-after-load' or a mode hook.
>
> (add-hook 'sh-mode-hook (lambda nil
> (define-key sh-mode-map "\M-#" 'variable-anlegen)))
>
> Would be sort of the usual way to do this. eval-after-load is rather
> an emergency measure and not desirable here.
My understanding was that `eval-after-load' is discouraged in
programs, but okay for user init files:
,----[ (info "(elisp)Hooks for Loading") ]
| You can ask for code to be executed if and when a particular library is
| loaded, by calling `eval-after-load'.
|
| [...]
|
| In general, well-designed Lisp programs should not use this feature.
| [...]
|
| But it is OK to use `eval-after-load' in your personal
| customizations if you don't feel they must meet the design standards for
| programs meant for wider use.
`----
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-22 10:02 ` Reiner Steib
@ 2006-06-22 13:58 ` Andreas Roehler
2006-06-22 14:44 ` David Kastrup
0 siblings, 1 reply; 17+ messages in thread
From: Andreas Roehler @ 2006-06-22 13:58 UTC (permalink / raw)
Reiner Steib wrote:
> On Thu, Jun 22 2006, David Kastrup wrote:
>
>> Reiner Steib <reinersteib+gmane@imap.cc> writes:
>>> Use `eval-after-load' or a mode hook.
>>
>> (add-hook 'sh-mode-hook (lambda nil
>> (define-key sh-mode-map "\M-#" 'variable-anlegen)))
>>
>> Would be sort of the usual way to do this. eval-after-load is
>> rather an emergency measure and not desirable here.
>
> My understanding was that `eval-after-load' is discouraged in
> programs, but okay for user init files:
>
> ,----[ (info "(elisp)Hooks for Loading") ]
> | You can ask for code to be executed if and when a particular
> | library is loaded, by calling `eval-after-load'.
> |
> | [...]
> |
> | In general, well-designed Lisp programs should not use
> | this feature.
> | [...]
> |
> | But it is OK to use `eval-after-load' in your personal
> | customizations if you don't feel they must meet the design
> | standards for programs meant for wider use.
> `----
>
> Bye, Reiner.
OK. Thanks to all responding my question. Obviously
there are several ways to do it.
As the question aimed towards usability here still a
draft of the situation a beginner is in - after reading
the tutorial and some further introductions:
He probably knows that
- there are modes to adapt the behavior
- there are keys to assign and beside `global-keys' it's
possible to specify mode-specific keys
- an init file ".emacs" reads in customizations
All the stuff with `eval-after-load' and even hooks are
too much at the beginning.
On the other side it should be possible with a
mode-name to assign a key on that level without deeper
knowledge.
An assignment as
(define-key sh-mode-map "\M-#" 'do-something)
should work instantly, as soon as sh-mode is activated.
Suggest to post the question to emacs-devel after the
forthcoming release, should it not be done then.
__
Andreas Roehler
PS: I would lobby to keep the shown names in the
mode-line the same as the real modes - major- and/or minor;
presently Shell-script[bash] i.e. is given at the mode-line when
`sh-mode' is on as major-mode. But that's a further question.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-22 13:58 ` Andreas Roehler
@ 2006-06-22 14:44 ` David Kastrup
2006-06-23 10:38 ` Andreas Roehler
2006-06-23 10:38 ` Andreas Roehler
0 siblings, 2 replies; 17+ messages in thread
From: David Kastrup @ 2006-06-22 14:44 UTC (permalink / raw)
Andreas Roehler <andreas.roehler@online.de> writes:
> An assignment as
>
> (define-key sh-mode-map "\M-#" 'do-something)
>
> should work instantly, as soon as sh-mode is activated.
^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You are aware that this is a complete contradiction, unless sh-mode is
activated instantly (hardly desirable)?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-22 14:44 ` David Kastrup
2006-06-23 10:38 ` Andreas Roehler
@ 2006-06-23 10:38 ` Andreas Roehler
2006-06-23 10:54 ` David Kastrup
1 sibling, 1 reply; 17+ messages in thread
From: Andreas Roehler @ 2006-06-23 10:38 UTC (permalink / raw)
David Kastrup wrote:
> Andreas Roehler <andreas.roehler@online.de> writes:
>
>> An assignment as
>>
>> (define-key sh-mode-map "\M-#" 'do-something)
>>
>> should work instantly, as soon as sh-mode is activated.
> ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> You are aware that this is a complete contradiction, unless
> sh-mode is activated instantly (hardly desirable)?
>
OK:
An assignment as
(define-key sh-mode-map "\M-#" 'do-something)
should work - i.e. at least be recorded for further use
-
also, if sh-mode isn't activated yet.
__
Andreas Roehler
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-22 14:44 ` David Kastrup
@ 2006-06-23 10:38 ` Andreas Roehler
2006-06-24 11:01 ` Peter Dyballa
[not found] ` <mailman.3284.1151146887.9609.help-gnu-emacs@gnu.org>
2006-06-23 10:38 ` Andreas Roehler
1 sibling, 2 replies; 17+ messages in thread
From: Andreas Roehler @ 2006-06-23 10:38 UTC (permalink / raw)
David Kastrup wrote:
> Andreas Roehler <andreas.roehler@online.de> writes:
>
>> An assignment as
>>
>> (define-key sh-mode-map "\M-#" 'do-something)
>>
>> should work instantly, as soon as sh-mode is activated.
> ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> You are aware that this is a complete contradiction, unless
> sh-mode is activated instantly (hardly desirable)?
>
OK:
An assignment as
(define-key sh-mode-map "\M-#" 'do-something)
should work - i.e. at least be recorded for further use
-
also, if sh-mode isn't activated yet.
__
Andreas Roehler
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-23 10:38 ` Andreas Roehler
@ 2006-06-23 10:54 ` David Kastrup
2006-06-23 20:51 ` Kevin Rodgers
2006-06-24 6:04 ` Andreas Roehler
0 siblings, 2 replies; 17+ messages in thread
From: David Kastrup @ 2006-06-23 10:54 UTC (permalink / raw)
Andreas Roehler <andreas.roehler@online.de> writes:
> David Kastrup wrote:
>
>> Andreas Roehler <andreas.roehler@online.de> writes:
>>
>>> An assignment as
>>>
>>> (define-key sh-mode-map "\M-#" 'do-something)
>>>
>>> should work instantly, as soon as sh-mode is activated.
>> ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> You are aware that this is a complete contradiction, unless
>> sh-mode is activated instantly (hardly desirable)?
>
> An assignment as
>
> (define-key sh-mode-map "\M-#" 'do-something)
>
> should work - i.e. at least be recorded for further use
> -
>
> also, if sh-mode isn't activated yet.
That would requires sh-mode-map to be defined before loading, or
define-key to work on undefined variables, and it would most certainly
cause any define-key in sh-mode.el to override the settings in .emacs.
All of this is not desirable. I recommend you read up a bit more
about Elisp before making proposals.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-23 10:54 ` David Kastrup
@ 2006-06-23 20:51 ` Kevin Rodgers
2006-06-23 22:08 ` Slawomir Nowaczyk
2006-06-24 6:04 ` Andreas Roehler
1 sibling, 1 reply; 17+ messages in thread
From: Kevin Rodgers @ 2006-06-23 20:51 UTC (permalink / raw)
David Kastrup wrote:
> Andreas Roehler <andreas.roehler@online.de> writes:
>> An assignment as
>>
>> (define-key sh-mode-map "\M-#" 'do-something)
>>
>> should work - i.e. at least be recorded for further use
>> -
>>
>> also, if sh-mode isn't activated yet.
>
> That would requires sh-mode-map to be defined before loading, or
> define-key to work on undefined variables, and it would most certainly
> cause any define-key in sh-mode.el to override the settings in .emacs.
>
> All of this is not desirable. I recommend you read up a bit more
> about Elisp before making proposals.
Why would it be undesirable to have sh-mode-map (and other keymaps)
already defined (by dumping it into emacs via an autoload cookie)?
--
Kevin
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-23 20:51 ` Kevin Rodgers
@ 2006-06-23 22:08 ` Slawomir Nowaczyk
2006-06-26 16:12 ` Kevin Rodgers
0 siblings, 1 reply; 17+ messages in thread
From: Slawomir Nowaczyk @ 2006-06-23 22:08 UTC (permalink / raw)
On Fri, 23 Jun 2006 14:51:04 -0600
Kevin Rodgers <ihs_4664@yahoo.com> wrote:
#> > All of this is not desirable. I recommend you read up a bit more
#> > about Elisp before making proposals.
#>
#> Why would it be undesirable to have sh-mode-map (and other keymaps)
#> already defined (by dumping it into emacs via an autoload cookie)?
When you say "other keymaps" do you mean only those that are part of
official Emacs distribution or those provided by additional modules
user might have installed as well?
--
Best wishes,
Slawomir Nowaczyk
( slawomir.nowaczyk.847@student.lu.se )
I asked Mom if I was a gifted child... she said they certainly
wouldn't have paid for me.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-23 10:54 ` David Kastrup
2006-06-23 20:51 ` Kevin Rodgers
@ 2006-06-24 6:04 ` Andreas Roehler
1 sibling, 0 replies; 17+ messages in thread
From: Andreas Roehler @ 2006-06-24 6:04 UTC (permalink / raw)
David Kastrup wrote:
> Andreas Roehler <andreas.roehler@online.de> writes:
>
>> David Kastrup wrote:
>>
I recommend you read up a bit
> more about Elisp before making proposals.
>
BTW: You should not discourage people making proposals
- might they be wright or wrong.
Even if they are wrong - as a developer you may learn,
what kind of errors they make. This too can be a
useful information.
Beside of this you were helpful a lot of times and
this is noticed.
__
Andreas Roehler
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-23 10:38 ` Andreas Roehler
@ 2006-06-24 11:01 ` Peter Dyballa
[not found] ` <mailman.3284.1151146887.9609.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 17+ messages in thread
From: Peter Dyballa @ 2006-06-24 11:01 UTC (permalink / raw)
Cc: help-gnu-emacs
Am 23.06.2006 um 12:38 schrieb Andreas Roehler:
> An assignment as
>
> (define-key sh-mode-map "\M-#" 'do-something)
>
> should work - i.e. at least be recorded for further use
And what happens when you load something that uses the same name "sh-
mode-map?"
Merge, substitue, forget? And then: which?
Although computers have the louder brains you should use your own
first. That's more ecological and more economical. So, first make
something available, and then modify it to avoid collisions and
misunderstandings later on!
Or do you drive a car as soon as you have received a driver's license?
--
Mit friedvollen Grüßen
Pete
"Isn't vi that text editor with two modes... one that beeps and one
that corrupts your file?" -- Dan Jacobson, on comp.os.linux.advocacy
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
[not found] ` <mailman.3284.1151146887.9609.help-gnu-emacs@gnu.org>
@ 2006-06-25 7:14 ` Andreas Roehler
2006-06-25 9:54 ` David Kastrup
0 siblings, 1 reply; 17+ messages in thread
From: Andreas Roehler @ 2006-06-25 7:14 UTC (permalink / raw)
Peter Dyballa wrote:
>
> Am 23.06.2006 um 12:38 schrieb Andreas Roehler:
>
>> An assignment as
>>
>> (define-key sh-mode-map "\M-#" 'do-something)
>>
>> should work - i.e. at least be recorded for further use
>
> And what happens when you load something that uses the same
> name "sh- mode-map?"
>
> Merge, substitue, forget? And then: which?
>
The key here is at `recorded'.
Following the discussion seen, probably I will use
`eval-after-load' next time instead of `require'.
Nonetheless the main issue also was not the
functioning as such but usability.
At least I see a chance to enhance the latter.
__
Andreas Roehler
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-25 7:14 ` Andreas Roehler
@ 2006-06-25 9:54 ` David Kastrup
0 siblings, 0 replies; 17+ messages in thread
From: David Kastrup @ 2006-06-25 9:54 UTC (permalink / raw)
Andreas Roehler <andreas.roehler@online.de> writes:
> Peter Dyballa wrote:
>
>>
>> Am 23.06.2006 um 12:38 schrieb Andreas Roehler:
>>
>>> An assignment as
>>>
>>> (define-key sh-mode-map "\M-#" 'do-something)
>>>
>>> should work - i.e. at least be recorded for further use
>>
>> And what happens when you load something that uses the same
>> name "sh- mode-map?"
>>
>> Merge, substitue, forget? And then: which?
>
> The key here is at `recorded'.
>
> Following the discussion seen, probably I will use
> `eval-after-load' next time instead of `require'.
>
> Nonetheless the main issue also was not the
> functioning as such but usability.
>
> At least I see a chance to enhance the latter.
It would also enhance the usability of cars if you could use tap water
instead of gasoline.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-23 22:08 ` Slawomir Nowaczyk
@ 2006-06-26 16:12 ` Kevin Rodgers
2006-06-27 12:03 ` Slawomir Nowaczyk
0 siblings, 1 reply; 17+ messages in thread
From: Kevin Rodgers @ 2006-06-26 16:12 UTC (permalink / raw)
Slawomir Nowaczyk wrote:
> On Fri, 23 Jun 2006 14:51:04 -0600
> Kevin Rodgers <ihs_4664@yahoo.com> wrote:
>
> #> > All of this is not desirable. I recommend you read up a bit more
> #> > about Elisp before making proposals.
> #>
> #> Why would it be undesirable to have sh-mode-map (and other keymaps)
> #> already defined (by dumping it into emacs via an autoload cookie)?
>
> When you say "other keymaps" do you mean only those that are part of
> official Emacs distribution or those provided by additional modules
> user might have installed as well?
Only those that are included in Emacs itself. But if the user wants to
build Emacs with 3rd party modules dumped, that's his/her business, and
the autoload mechanism can be used for them as well.
--
Kevin
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: emacs init and mode-maps
2006-06-26 16:12 ` Kevin Rodgers
@ 2006-06-27 12:03 ` Slawomir Nowaczyk
0 siblings, 0 replies; 17+ messages in thread
From: Slawomir Nowaczyk @ 2006-06-27 12:03 UTC (permalink / raw)
On Mon, 26 Jun 2006 10:12:33 -0600
Kevin Rodgers <ihs_4664@yahoo.com> wrote:
#>>> Why would it be undesirable to have sh-mode-map (and other
#>>> keymaps) already defined (by dumping it into emacs via an
#>>> autoload cookie)?
#>>
#>> When you say "other keymaps" do you mean only those that are part
#>> of official Emacs distribution or those provided by additional
#>> modules user might have installed as well?
#>
#> Only those that are included in Emacs itself.
In that case, I would answer your earlier question with "because it
creates an asymmetry between how built-in and external packages work."
Honestly, I do not quite see the point of your suggestion. It seems to
me that loading a package when you want it sufficiently easy to do.
And autoloading everything doesn't strike me as a good idea.
--
Best wishes,
Slawomir Nowaczyk
( slawomir.nowaczyk.847@student.lu.se )
Programmer - A red-eyed, mumbling mammal
capable of conversing with inanimate objects.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2006-06-27 12:03 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-22 7:17 emacs init and mode-maps Andreas Roehler
2006-06-22 8:58 ` Reiner Steib
2006-06-22 9:22 ` David Kastrup
2006-06-22 10:02 ` Reiner Steib
2006-06-22 13:58 ` Andreas Roehler
2006-06-22 14:44 ` David Kastrup
2006-06-23 10:38 ` Andreas Roehler
2006-06-24 11:01 ` Peter Dyballa
[not found] ` <mailman.3284.1151146887.9609.help-gnu-emacs@gnu.org>
2006-06-25 7:14 ` Andreas Roehler
2006-06-25 9:54 ` David Kastrup
2006-06-23 10:38 ` Andreas Roehler
2006-06-23 10:54 ` David Kastrup
2006-06-23 20:51 ` Kevin Rodgers
2006-06-23 22:08 ` Slawomir Nowaczyk
2006-06-26 16:12 ` Kevin Rodgers
2006-06-27 12:03 ` Slawomir Nowaczyk
2006-06-24 6:04 ` Andreas Roehler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).