* Adding a sublist to a list on startup
@ 2010-12-13 19:55 Tyler Smith
2010-12-13 21:17 ` Drew Adams
2010-12-15 4:18 ` Kevin Rodgers
0 siblings, 2 replies; 11+ messages in thread
From: Tyler Smith @ 2010-12-13 19:55 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I need to customize the variable LaTeX-environment-list in Auctex. To
get the behaviour I want, I have included the following in my .emacs:
(defun my-LaTeX-hook ()
(push '("choices" . LaTeX-insert-choice) LaTeX-item-list)
(push '("parts" . LaTeX-insert-part) LaTeX-item-list)
(push '("questions" . LaTeX-insert-question) LaTeX-item-list)
(push '("choices" LaTeX-env-item) LaTeX-environment-list)
(push '("questions" LaTeX-env-item) LaTeX-environment-list)
(push '("parts" LaTeX-env-item) LaTeX-environment-list))
(add-hook 'LaTeX-mode-hook 'my-LaTeX-hook)
However, the last three push commands aren't doing what I expect. If I
evaluate them from a buffer that is in Auctex/LaTeX mode, the value of
LaTeX-environment-list contains:
Value:
(("abstract")
("array" LaTeX-env-array)
("center")
("choices" LaTeX-env-item)
;; Extra lines snipped
("verse"))
However, my hook doesn't work properly - it gives me this instead:
Value:
((LaTeX-env-item)
("abstract")
("array" LaTeX-env-array)
("center")
("choices")
;; Extra lines snipped
("verse"))
So the two-element list I'm trying to add to LaTeX-environment-list is
getting split into two atoms, each added as a separate list. I guess I'm
modifying something at the wrong time, but I'm not sure exactly what.
Help?
Thanks,
Tyler
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: Adding a sublist to a list on startup
2010-12-13 19:55 Adding a sublist to a list on startup Tyler Smith
@ 2010-12-13 21:17 ` Drew Adams
2010-12-13 21:31 ` Tyler Smith
2010-12-15 4:18 ` Kevin Rodgers
1 sibling, 1 reply; 11+ messages in thread
From: Drew Adams @ 2010-12-13 21:17 UTC (permalink / raw)
To: 'Tyler Smith', help-gnu-emacs
> (defun my-LaTeX-hook ()
> (push '("choices" . LaTeX-insert-choice) LaTeX-item-list)
> (push '("parts" . LaTeX-insert-part) LaTeX-item-list)
> (push '("questions" . LaTeX-insert-question) LaTeX-item-list)
> (push '("choices" LaTeX-env-item) LaTeX-environment-list)
> (push '("questions" LaTeX-env-item) LaTeX-environment-list)
> (push '("parts" LaTeX-env-item) LaTeX-environment-list))
>
> (add-hook 'LaTeX-mode-hook 'my-LaTeX-hook)
>
> However, the last three push commands aren't doing what I expect.
I haven't used LaTeX in years (unfortunately), but is it perhaps because the
last three don't have a dot (.)?
I also wonder why you don't just use Customize to customize `LaTeX-item-list'
(I'm assuming that it is a user option). That's what Customize is for: it
type-checks changes you make.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Adding a sublist to a list on startup
2010-12-13 21:17 ` Drew Adams
@ 2010-12-13 21:31 ` Tyler Smith
2010-12-13 21:57 ` Drew Adams
0 siblings, 1 reply; 11+ messages in thread
From: Tyler Smith @ 2010-12-13 21:31 UTC (permalink / raw)
To: help-gnu-emacs
"Drew Adams" <drew.adams@oracle.com> writes:
>> (defun my-LaTeX-hook ()
>> (push '("choices" . LaTeX-insert-choice) LaTeX-item-list)
>> (push '("parts" . LaTeX-insert-part) LaTeX-item-list)
>> (push '("questions" . LaTeX-insert-question) LaTeX-item-list)
>> (push '("choices" LaTeX-env-item) LaTeX-environment-list)
>> (push '("questions" LaTeX-env-item) LaTeX-environment-list)
>> (push '("parts" LaTeX-env-item) LaTeX-environment-list))
>>
>> (add-hook 'LaTeX-mode-hook 'my-LaTeX-hook)
>>
>> However, the last three push commands aren't doing what I expect.
>
> I haven't used LaTeX in years (unfortunately), but is it perhaps because the
> last three don't have a dot (.)?
No, sorry, there are two different lists getting modified there. The
first three pushes add to LaTeX-item-list, which is an alist (thus the
dots). This seems to work as expected. The second group of pushes adds
to LaTeX-environment-list, which is a list of two-element lists (no
dots).
>
> I also wonder why you don't just use Customize to customize `LaTeX-item-list'
> (I'm assuming that it is a user option). That's what Customize is for: it
> type-checks changes you make.
Two reasons. First, these are not customizable variables, so I can't.
Second, even if I could use customize, trying to figure out how to enter
anything more complex than a string, or selecting a checkbox, is, in my
limited experience, harder than just figuring out the lisp. It took me
forever to understand how to customize the sgml tag alist, for example,
but maybe that's just me.
In any case, I think it would be useful to either extend the built-in
values of these variables, or provide some simple user-accessible way to
modify them. Once I get it to do what I want it to I'll send a
suggestion/patch to the Auctex people.
Cheers,
Tyler
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: Adding a sublist to a list on startup
2010-12-13 21:31 ` Tyler Smith
@ 2010-12-13 21:57 ` Drew Adams
2010-12-16 13:52 ` Tyler Smith
0 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2010-12-13 21:57 UTC (permalink / raw)
To: 'Tyler Smith', help-gnu-emacs
> No, sorry, there are two different lists getting modified there. The
> first three pushes add to LaTeX-item-list, which is an alist (thus the
> dots). This seems to work as expected. The second group of pushes adds
> to LaTeX-environment-list, which is a list of two-element lists (no
> dots).
M-x debug-on-entry RET my-LaTeX-hook RET
Then use `d' to step through the function. You can use `e' at any time to
evaluate something (e.g. `LaTeX-env-item'). That should show you what the
problem is.
> > I also wonder why you don't just use Customize to customize
> > `LaTeX-item-list' (I'm assuming that it is a user option).
> > That's what Customize is for: it type-checks changes you make.
>
> Two reasons. First, these are not customizable variables, so I can't.
That would be the first bug/enhancement request I would make, if I were in your
place.
> Second, even if I could use customize, trying to figure out
> how to enter anything more complex than a string, or selecting
> a checkbox, is, in my limited experience, harder than just
> figuring out the lisp.
Sometimes the person who defined the `defcustom' is lazy. ;-)
In this case, if `LaTeX-environment-list' is a list of items that are each
always a list of a string and a symbol, something like this shouldn't be
difficult to deal with in Customize:
(defcustom LaTeX-environment-list () "..."
:type '(repeat (list string symbol)) :group 'whatever)
The only fields to fill in are a string and a symbol name for each item. Plus
buttons INS and DEL to add or delete an item.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Adding a sublist to a list on startup
2010-12-13 19:55 Adding a sublist to a list on startup Tyler Smith
2010-12-13 21:17 ` Drew Adams
@ 2010-12-15 4:18 ` Kevin Rodgers
2010-12-15 15:21 ` Tyler Smith
1 sibling, 1 reply; 11+ messages in thread
From: Kevin Rodgers @ 2010-12-15 4:18 UTC (permalink / raw)
To: help-gnu-emacs
On 12/13/10 12:55 PM, Tyler Smith wrote:
> Hi,
>
> I need to customize the variable LaTeX-environment-list in Auctex. To
> get the behaviour I want, I have included the following in my .emacs:
>
> (defun my-LaTeX-hook ()
> (push '("choices" . LaTeX-insert-choice) LaTeX-item-list)
> (push '("parts" . LaTeX-insert-part) LaTeX-item-list)
> (push '("questions" . LaTeX-insert-question) LaTeX-item-list)
> (push '("choices" LaTeX-env-item) LaTeX-environment-list)
> (push '("questions" LaTeX-env-item) LaTeX-environment-list)
> (push '("parts" LaTeX-env-item) LaTeX-environment-list))
>
> (add-hook 'LaTeX-mode-hook 'my-LaTeX-hook)
>
> However, the last three push commands aren't doing what I expect. If I
> evaluate them from a buffer that is in Auctex/LaTeX mode, the value of
> LaTeX-environment-list contains:
>
> Value:
> (("abstract")
> ("array" LaTeX-env-array)
> ("center")
> ("choices" LaTeX-env-item)
> ;; Extra lines snipped
> ("verse"))
>
> However, my hook doesn't work properly - it gives me this instead:
>
> Value:
> ((LaTeX-env-item)
> ("abstract")
> ("array" LaTeX-env-array)
> ("center")
> ("choices")
> ;; Extra lines snipped
> ("verse"))
>
> So the two-element list I'm trying to add to LaTeX-environment-list is
> getting split into two atoms, each added as a separate list. I guess I'm
> modifying something at the wrong time, but I'm not sure exactly what.
Are you sure that's the version of my-LaTeX-hook that's being executed?
(It could be redefined by something loaded later, or perhaps you've got
a compiled version of .emacs that is being loaded instead.)
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Adding a sublist to a list on startup
2010-12-15 4:18 ` Kevin Rodgers
@ 2010-12-15 15:21 ` Tyler Smith
2010-12-16 7:18 ` Kevin Rodgers
0 siblings, 1 reply; 11+ messages in thread
From: Tyler Smith @ 2010-12-15 15:21 UTC (permalink / raw)
To: help-gnu-emacs
Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
>>
>> So the two-element list I'm trying to add to LaTeX-environment-list is
>> getting split into two atoms, each added as a separate list. I guess I'm
>> modifying something at the wrong time, but I'm not sure exactly what.
>
> Are you sure that's the version of my-LaTeX-hook that's being executed?
> (It could be redefined by something loaded later, or perhaps you've got
> a compiled version of .emacs that is being loaded instead.)
That was a good idea, but I just searched my .emacs.d/init.el, and
there's only one instance of my-LaTeX-hook. I've never compiled my
config file, and grep tells me there are no other files in .emacs.d that
have that variable in them.
Thanks,
Tyler
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Adding a sublist to a list on startup
2010-12-15 15:21 ` Tyler Smith
@ 2010-12-16 7:18 ` Kevin Rodgers
0 siblings, 0 replies; 11+ messages in thread
From: Kevin Rodgers @ 2010-12-16 7:18 UTC (permalink / raw)
To: help-gnu-emacs
On 12/15/10 8:21 AM, Tyler Smith wrote:
> Kevin Rodgers<kevin.d.rodgers@gmail.com> writes:
>>>
>>> So the two-element list I'm trying to add to LaTeX-environment-list is
>>> getting split into two atoms, each added as a separate list. I guess I'm
>>> modifying something at the wrong time, but I'm not sure exactly what.
>>
>> Are you sure that's the version of my-LaTeX-hook that's being executed?
>> (It could be redefined by something loaded later, or perhaps you've got
>> a compiled version of .emacs that is being loaded instead.)
>
> That was a good idea, but I just searched my .emacs.d/init.el, and
> there's only one instance of my-LaTeX-hook. I've never compiled my
> config file, and grep tells me there are no other files in .emacs.d that
> have that variable in them.
One final check, does this return what you expect:
(symbol-function 'my-LaTeX-hook)
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Adding a sublist to a list on startup
2010-12-13 21:57 ` Drew Adams
@ 2010-12-16 13:52 ` Tyler Smith
2010-12-16 14:52 ` Drew Adams
2010-12-16 16:48 ` PJ Weisberg
0 siblings, 2 replies; 11+ messages in thread
From: Tyler Smith @ 2010-12-16 13:52 UTC (permalink / raw)
To: help-gnu-emacs
"Drew Adams" <drew.adams@oracle.com> writes:
>> No, sorry, there are two different lists getting modified there. The
>> first three pushes add to LaTeX-item-list, which is an alist (thus the
>> dots). This seems to work as expected. The second group of pushes adds
>> to LaTeX-environment-list, which is a list of two-element lists (no
>> dots).
>
> M-x debug-on-entry RET my-LaTeX-hook RET
>
> Then use `d' to step through the function. You can use `e' at any time to
> evaluate something (e.g. `LaTeX-env-item'). That should show you what the
> problem is.
>
Finally got round to trying this. I can use e to evaluate items, but d
gives me an error at the top of the buffer:
Debugger entered--Lisp error: (error "Cannot return from the debugger in
an error")
Which I take to mean there is some error in the hook?
The full hook is pasted below. It looks correct to me, but maybe I've
missed something?
(defun my-LaTeX-hook ()
(TeX-PDF-mode)
(auto-fill-mode)
(face-remap-set-base 'default '(:family "Verdana" :height 140))
(setq TeX-command-default "PdfLatex")
(push '("choices" . LaTeX-insert-choice) LaTeX-item-list)
(push '("parts" . LaTeX-insert-part) LaTeX-item-list)
(push '("questions" . LaTeX-insert-question) LaTeX-item-list)
(push '("choices" LaTeX-env-item) LaTeX-environment-list)
(push '("questions" LaTeX-env-item) LaTeX-environment-list)
(push '("parts" LaTeX-env-item) LaTeX-environment-list))
Thanks,
Tyler
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: Adding a sublist to a list on startup
2010-12-16 13:52 ` Tyler Smith
@ 2010-12-16 14:52 ` Drew Adams
2010-12-17 2:43 ` Tyler Smith
2010-12-16 16:48 ` PJ Weisberg
1 sibling, 1 reply; 11+ messages in thread
From: Drew Adams @ 2010-12-16 14:52 UTC (permalink / raw)
To: 'Tyler Smith', help-gnu-emacs
> > M-x debug-on-entry RET my-LaTeX-hook RET
> >
> > Then use `d' to step through the function. You can use `e'
> > at any time to evaluate something (e.g. `LaTeX-env-item'). That should
> > show you what the problem is.
>
> Finally got round to trying this. I can use e to evaluate items, but d
> gives me an error at the top of the buffer:
>
> Debugger entered--Lisp error: (error "Cannot return from the
> debugger in an error")
> Which I take to mean there is some error in the hook?
That error message is shown if you try to hit `d' or `c' _after_ an error has
already occurred. If it happens for the _first_ `d' or `c' you hit in the
debugger, then you should already see an error message (at the top) upon entry.
In that case, look up the backtrace stack (i.e. down the buffer) to see which
function raised the error, and debug that function instead (`debug-on-entry').
The point is that you can use `d' to step through a function, but once you hit
an error you can no longer step (where would it step?).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Adding a sublist to a list on startup
2010-12-16 13:52 ` Tyler Smith
2010-12-16 14:52 ` Drew Adams
@ 2010-12-16 16:48 ` PJ Weisberg
1 sibling, 0 replies; 11+ messages in thread
From: PJ Weisberg @ 2010-12-16 16:48 UTC (permalink / raw)
To: Tyler Smith; +Cc: help-gnu-emacs
On Thu, Dec 16, 2010 at 5:52 AM, Tyler Smith <tyler.smith@eku.edu> wrote:
> (defun my-LaTeX-hook ()
Looks like you just copy-and-pasted that from where you define it.
Just as a sanity check to make sure it's really, really defined the
way you think it is, do this:
M-x pp-eval-expression
(symbol-function 'my-LaTeX-hook)
-PJ
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Adding a sublist to a list on startup
2010-12-16 14:52 ` Drew Adams
@ 2010-12-17 2:43 ` Tyler Smith
0 siblings, 0 replies; 11+ messages in thread
From: Tyler Smith @ 2010-12-17 2:43 UTC (permalink / raw)
To: help-gnu-emacs
"Drew Adams" <drew.adams@oracle.com> writes:
>> > M-x debug-on-entry RET my-LaTeX-hook RET
>> >
>
Turns out debug-on-entry is smarter than I am. I'm going to have to read
up on that one. Looks really useful, but I don't understand it at all.
In the meantime, I discovered the source of my problems. I hadn't
realized how deep the lists were nested in the undocumented variable
LaTeX-environment-list. Wrapping my new lists in another pair of parens
makes everything work just fine.
There is still some mysterious magic going on, but I couldn't actually
find the original definition of the variable. I have sent a note to the
AucTex people to let them know about the issue.
Thanks for your help,
Tyler
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-12-17 2:43 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-13 19:55 Adding a sublist to a list on startup Tyler Smith
2010-12-13 21:17 ` Drew Adams
2010-12-13 21:31 ` Tyler Smith
2010-12-13 21:57 ` Drew Adams
2010-12-16 13:52 ` Tyler Smith
2010-12-16 14:52 ` Drew Adams
2010-12-17 2:43 ` Tyler Smith
2010-12-16 16:48 ` PJ Weisberg
2010-12-15 4:18 ` Kevin Rodgers
2010-12-15 15:21 ` Tyler Smith
2010-12-16 7:18 ` Kevin Rodgers
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).