all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* problem getting hooks to be active
@ 2003-08-11 17:34 Eric Pement
  2003-08-11 17:45 ` Peter Solodov
  2003-08-15 12:59 ` Kai Großjohann
  0 siblings, 2 replies; 11+ messages in thread
From: Eric Pement @ 2003-08-11 17:34 UTC (permalink / raw)


I'm trying to customize a few variables in sgml-mode (xml-mode), but
the settings I want are not being obeyed. I don't know why, so I
thought I'd post my .emacs snippet here and maybe someone could tell
me what I'm doing wrong:

   (add-hook 'sgml-mode-hook'
        (lambda ()
          (setq tab-width 2)
          (setq indent-tabs-mode nil)
	  (setq fill-column 85)
   ))

What I want should be obvious. When editing XML files, I want to
change my tab width, fill column, and intent-tabs-mode behavior. But
my alterations aren't being obeyed. I've tried adding --debug-init on
the command line, but it doesn't bring up the debugger at all. I've
tried doing M-x eval-buffer while editing my .emacs file, and
eval-last-sexp after the function above, and gotten no error messages
that I can detect. Any advice?

I'm running GNU Emacs version 21.1.1 on Windows 2000 Pro, with 4NT as
the basic shell.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-11 17:34 problem getting hooks to be active Eric Pement
@ 2003-08-11 17:45 ` Peter Solodov
  2003-08-11 18:26   ` Johan Bockgård
  2003-08-11 18:30   ` Barry Margolin
  2003-08-15 12:59 ` Kai Großjohann
  1 sibling, 2 replies; 11+ messages in thread
From: Peter Solodov @ 2003-08-11 17:45 UTC (permalink / raw)


On 11 Aug 2003, Eric Pement wrote:
>    (add-hook 'sgml-mode-hook'

That second quote is really there???  In this case you're adding to
"sgml-mode-hook'", and not sgml-mode-hook.

(add-hook 'sgml-mode-hook
  (lambda ()
    ...

        - Peter

-- 
Peter Solodov                    | Concordia University 
http://alcor.concordia.ca/~peter | Montreal, QC, Canada

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-11 17:45 ` Peter Solodov
@ 2003-08-11 18:26   ` Johan Bockgård
  2003-08-11 18:30   ` Barry Margolin
  1 sibling, 0 replies; 11+ messages in thread
From: Johan Bockgård @ 2003-08-11 18:26 UTC (permalink / raw)


Peter Solodov <peter@alcor.concordia.ca> writes:

> On 11 Aug 2003, Eric Pement wrote:
>>    (add-hook 'sgml-mode-hook'
>
> That second quote is really there??? In this case you're adding to
> "sgml-mode-hook'", and not sgml-mode-hook.

Strange. No, the second quote shouldn't really be there. However, it
still works here (Emacs 21.2) as written.

(list 'foo' bar) => (foo bar)

And the lambda expression evaluates to itself anyway.

-- 
Join us on #emacs @ irc.freenode.net.
http://www.emacswiki.org/cgi-bin/wiki.pl/EmacsChannel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-11 17:45 ` Peter Solodov
  2003-08-11 18:26   ` Johan Bockgård
@ 2003-08-11 18:30   ` Barry Margolin
  2003-08-12 16:32     ` Eric Pement
  1 sibling, 1 reply; 11+ messages in thread
From: Barry Margolin @ 2003-08-11 18:30 UTC (permalink / raw)


In article <87ptjc3x6r.fsf@lorien.concordia.ca>,
Peter Solodov  <peter@alcor.concordia.ca> wrote:
>On 11 Aug 2003, Eric Pement wrote:
>>    (add-hook 'sgml-mode-hook'
>
>That second quote is really there???  In this case you're adding to
>"sgml-mode-hook'", and not sgml-mode-hook.

No he isn't.  Lisp has no provisions for turning single-quotes into
double-quotes.  What he wrote is actually equivalent to:

(add-hook 'sgml-mode-hook
  '(lambda ...))

because Lisp doesn't care about the presence or absence of whitespace
before or after quotes.

But I agree that his layout suggests a serious misunderstanding of how Lisp
quoting works.

>(add-hook 'sgml-mode-hook
>  (lambda ()
>    ...

That should work the same as his version, because (lambda ...) is a macro
invocation that expands into '(lambda ...).

-- 
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-11 18:30   ` Barry Margolin
@ 2003-08-12 16:32     ` Eric Pement
  2003-08-12 16:54       ` Peter Solodov
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Pement @ 2003-08-12 16:32 UTC (permalink / raw)


Barry Margolin <barry.margolin@level3.com> wrote in message news:<UgRZa.122$7R.48@news.level3.com>...
> In article <87ptjc3x6r.fsf@lorien.concordia.ca>,
> Peter Solodov  <peter@alcor.concordia.ca> wrote:
> >On 11 Aug 2003, Eric Pement wrote:
> >>    (add-hook 'sgml-mode-hook'
> >
> >That second quote is really there???  In this case you're adding to
> >"sgml-mode-hook'", and not sgml-mode-hook.
> 
> No he isn't.  [ ... ]

> But I agree that his layout suggests a serious misunderstanding of how Lisp
> quoting works.
> 
> >(add-hook 'sgml-mode-hook
> >  (lambda ()
> >    ...

I wonder if I should expect this?  Three people respond to my
question, all of them nitpicking about a quote mark that doesn't
affect the failure or success of the code. Yes, the extra quote mark
in 'sgml-mode-hook' was an ignorant mistake. I copied it off a sample
ini file on www.dotemacs.de. Removing the trailing apostrophe does not
fix the problem.

So what should I have written instead that will change the variables
while in sgml-mode?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-12 16:32     ` Eric Pement
@ 2003-08-12 16:54       ` Peter Solodov
  2003-08-15 14:54         ` Eric Pement
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Solodov @ 2003-08-12 16:54 UTC (permalink / raw)


On 12 Aug 2003, Eric Pement wrote:
> So what should I have written instead that will change the variables
> while in sgml-mode?

(add-hook 'sgml-mode-hook
  (lambda ()
    (setq tab-width 2)
    (setq indent-tabs-mode nil)
    (setq fill-column 85)))

That code worked just now.  It doesn't appear very different (or at
all) from what you've shown.

Put code above into "*scratch*" buffer and evaluate it (press "C-x
C-e" at the end of the last line).  Then try to open SGML file.  If
that works, then you're not putting your code into the right place.

        - Peter

-- 
Peter Solodov                    | Concordia University 
http://alcor.concordia.ca/~peter | Montreal, QC, Canada

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-11 17:34 problem getting hooks to be active Eric Pement
  2003-08-11 17:45 ` Peter Solodov
@ 2003-08-15 12:59 ` Kai Großjohann
  2003-08-20 15:46   ` Eric Pement
  2003-08-20 17:29   ` Eric Pement
  1 sibling, 2 replies; 11+ messages in thread
From: Kai Großjohann @ 2003-08-15 12:59 UTC (permalink / raw)


pemente@northpark.edu (Eric Pement) writes:

>    (add-hook 'sgml-mode-hook'
>         (lambda ()
>           (setq tab-width 2)

Do you know what tab-width does?  I'm guessing that the code is doing
what you tell it to, but it's not what you expect.

If the file contains literal tab characters, then the above line will
change how they are shown on screen.  It has absolutely (well,
almost) nothing to do with the TAB key.

>           (setq indent-tabs-mode nil)

Hm.  Well, do you have tab characters in your files?

> 	  (setq fill-column 85)

How do you know it is not taking effect?  What happens when you hit M-q?

>    ))

A completely wild speculation is that you actually want to set
sgml-indent-data to t to make it indent more often.  Then you want to
set sgml-indent-step to 2 (which is the default, afaik).

And for filling, maybe you want to turn on auto-fill mode?

Does this help?

If it doesn't, please explain in more detail what is happening.  For
example, show us an XML file, then describe which keys you press at
which location, and then show us the result you get and the result
you want to get instead.
-- 
Two cafe au lait please, but without milk.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-12 16:54       ` Peter Solodov
@ 2003-08-15 14:54         ` Eric Pement
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Pement @ 2003-08-15 14:54 UTC (permalink / raw)


Peter Solodov <peter@alcor.concordia.ca> wrote in message news:<87isp2u895.fsf@lorien.concordia.ca>...
> On 12 Aug 2003, Eric Pement wrote:
> > So what should I have written instead that will change the variables
> > while in sgml-mode?
> 
> (add-hook 'sgml-mode-hook
>   (lambda ()
>     (setq tab-width 2)
>     (setq indent-tabs-mode nil)
>     (setq fill-column 85)))
> 
> That code worked just now.  It doesn't appear very different (or at
> all) from what you've shown.
> 
> Put code above into "*scratch*" buffer and evaluate it (press "C-x
> C-e" at the end of the last line).  Then try to open SGML file.  If
> that works, then you're not putting your code into the right place.
> 
>         - Peter

Wow, that was really a great answer. Thanks for being so direct and
helpful. As it turns out, it worked when I put it into the *scratch*
buffer and followed your instructions. But when I put it into my
.emacs file, it doesn't work. I tried moving it to the very FIRST
instruction at the top, and also to practically the LAST instruction
... technically, just above the "custom-set-variables" line. But in
neither case does it change things for my XML files. (sigh)

I guess my next step is a slow, line-by-line debug. Well, at least
you've put me on the right track. I think I can manage from here.

--
Eric Pement

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-15 12:59 ` Kai Großjohann
@ 2003-08-20 15:46   ` Eric Pement
  2003-08-24 12:58     ` Kai Großjohann
  2003-08-20 17:29   ` Eric Pement
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Pement @ 2003-08-20 15:46 UTC (permalink / raw)


kai.grossjohann@gmx.net (Kai Großjohann) wrote in message news:<84u18j2i16.fsf@slowfox.is.informatik.uni-duisburg.de>...
> pemente@northpark.edu (Eric Pement) writes:
> 
> >    (add-hook 'sgml-mode-hook'
> >         (lambda ()
> >           (setq tab-width 2)
> 
> Do you know what tab-width does?

   Yes. It controls the number of columns that are used to represent
TAB characters embedded in the document. (As an aside, I have a page
on Emacs and Tabs here, which is the limits of my knowledge here:
http://www.student.northpark.edu/pemente/emacs_tabs.htm)

> I'm guessing that the code is doing
> what you tell it to, but it's not what you expect.

   Normally, that's a reasonable guess, but C-h v (describe-variable)
confirms that my variables are not being set. When I followed the
advice of Peter Solodov to evaluate the code in the *scratch* buffer,
I instantly recognize the change, so my guess for now is that I have
other code in my .emacs file which conflicts with it.

> Hm.  Well, do you have tab characters in your files?

   Yes. Basically, I edit XML files written by other people, people
who don't know about TABS and have no preference either way. The
spacing is inconsistent and irregular (regardless of which tab-width I
select), and so I'd want to use just hard spaces for spacing, so
whoever works on these files after me will at least have something
consistent to work with.


> A completely wild speculation is that you actually want to set
> sgml-indent-data to t to make it indent more often.  Then you want to
> set sgml-indent-step to 2 (which is the default, afaik).

    But the problem is that none of the settings in the "block" are
being obeyed. But I can try your suggestion manually and see what
results I get.

> And for filling, maybe you want to turn on auto-fill mode?

   Already on, along with abbrev-mode (a real time-saver for me).


> Does this help?

   It's encouraging to get good responses. I'll try your suggestions
about sgml-indent-data and sgml-indent-step to see what I get. Thanks
for answering.

-- 
Eric Pement

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-15 12:59 ` Kai Großjohann
  2003-08-20 15:46   ` Eric Pement
@ 2003-08-20 17:29   ` Eric Pement
  1 sibling, 0 replies; 11+ messages in thread
From: Eric Pement @ 2003-08-20 17:29 UTC (permalink / raw)


kai.grossjohann@gmx.net (Kai Großjohann) wrote in message news:<84u18j2i16.fsf@slowfox.is.informatik.uni-duisburg.de>...

> A completely wild speculation is that you actually want to set
> sgml-indent-data to t to make it indent more often.  Then you want to
> set sgml-indent-step to 2 (which is the default, afaik).
> 
> And for filling, maybe you want to turn on auto-fill mode?
> 
> Does this help?
> 
> If it doesn't, please explain in more detail what is happening.

Solution found!

The problem was that none of my changes were taking effect. I had
redefined the variables in sgml-mode, but they were being ignored.
Nothing was happening.

Then while working on the command-line, trying to debug the .emacs
init file, I found the problem: I had byte-compiled my .emacs file
previously, but had not byte-compiled the .emacs file after I had
changed and saved it. So Emacs was loading the older .emacs.elc file
instead of the newer .emacs file.

Solution was simple: byte-compile the new .emacs file and everything
works. (*sigh*) How did I miss this one? Must have been the Sobig
virus working on my brain. :)

--
Eric Pement

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: problem getting hooks to be active
  2003-08-20 15:46   ` Eric Pement
@ 2003-08-24 12:58     ` Kai Großjohann
  0 siblings, 0 replies; 11+ messages in thread
From: Kai Großjohann @ 2003-08-24 12:58 UTC (permalink / raw)


pemente@northpark.edu (Eric Pement) writes:

> kai.grossjohann@gmx.net (Kai Großjohann) wrote in message news:<84u18j2i16.fsf@slowfox.is.informatik.uni-duisburg.de>...
>> pemente@northpark.edu (Eric Pement) writes:
>> 
>> >    (add-hook 'sgml-mode-hook'
>> >         (lambda ()
>> >           (setq tab-width 2)
>> 
>> Do you know what tab-width does?
>
>    Yes. It controls the number of columns that are used to represent
> TAB characters embedded in the document.

*blush*

Can anyone point out a mousehole for me to crawl into?

(What's the right idiom for this?  I just translated a German one.)
-- 
Two cafe au lait please, but without milk.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-08-24 12:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-11 17:34 problem getting hooks to be active Eric Pement
2003-08-11 17:45 ` Peter Solodov
2003-08-11 18:26   ` Johan Bockgård
2003-08-11 18:30   ` Barry Margolin
2003-08-12 16:32     ` Eric Pement
2003-08-12 16:54       ` Peter Solodov
2003-08-15 14:54         ` Eric Pement
2003-08-15 12:59 ` Kai Großjohann
2003-08-20 15:46   ` Eric Pement
2003-08-24 12:58     ` Kai Großjohann
2003-08-20 17:29   ` Eric Pement

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.