[Top][All Lists]

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

Re: `comment-start' is nil

From: lee
Subject: Re: `comment-start' is nil
Date: Sat, 15 Mar 2014 21:50:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Juanma Barranquero <address@hidden> writes:

> On Wed, Mar 12, 2014 at 10:37 PM, lee <address@hidden> wrote:
>> I´m using desktop-mode to restore the previous session when starting
>> emacs.  For some buffers that are restored this way, I´m using a mode
>> I´m working on.  This mode employs a function to search for a regex in
>> particular buffers.  The regex involves `comment-start'.
>> Unfortunately, at the time the function is running during start-up, the
>> value of `comment-start' is nil.
>>     (let ((end-marker (concat "^" comment-start 
>> lsl-hi-lock-patterns-end-marker)))
>>         (message "comment-start with %s is %s"
>>            (buffer-name)
>>            comment-start) ...)
>> gives me messages like "comment-start with test-plane.fontify is nil".
>> Calling the same function later works fine because `comment-start' isn´t
>> nil anymore.
> We'll need more information. It is a major mode or a minor mode?

(define-derived-mode lsl-mode c++-mode "LSL" ...

I`m not sure if it`s major or minor.  The docstring says it`s major, but
I didn`t write that part of it.

> If a minor, which major mode are these buffers?

Hm, I think it`s a major mode; "LSL" shows up first in the mode line.

> How it is your function run during the startup?

Please see --- I
just pushed the latest version, it`s work in progress.

`lsl-mode-apply-hi-lock-patterns' (in lsl-mode.el) is called when the
mode is enabled.  It uses the variable lsl-hi-lock-patterns-file to
figure out from which file to read highlighting patterns.

lsl-hi-lock-patterns-file should be set from the '-*-' line in the
buffer.  By the time the mode is enabled during startup, this variable
is not set.

I have a work-around in place so my code reads the variable from the
'-*-' when it`s not set.

> How does the function get the buffer to run into?

  (unless (assoc-default "\\.lsl$" auto-mode-alist)
    (add-to-list 'auto-mode-alist '("\\.lsl$" . lsl-mode))))

... in `lsl-mode-auto-enable'.

Desktop-mode seems to play into this in that it apparently remembers the
modes of a buffer and re-enables them when restoring the buffers.

Knowledge is volatile and fluid.  Software is power.

reply via email to

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