emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: eval-print-last-sexp and newline


From: Stefan Monnier
Subject: Re: eval-print-last-sexp and newline
Date: Mon, 02 Jun 2003 12:44:08 -0400

> Th following code seem to indent correctly with "emacs -nw".  Making
> it indent currectly under X would require either to stop using buton
> face for "[ins]" and "[del]", or to teach widget about propertional
> fonts. 

I don't care about this kind of misalignment.  The problem I'm seeing
is with twi lines that should have the same number of leading spaces
but one of tham has twice as many.

> (defcustom latex-block-args-alist
>   '(("array" nil ?\{ (skeleton-read "[options]: ") ?\})
>     ("tabular" nil ?\{ (skeleton-read "[options]: ") ?\}))
>   "Skeleton element to use for arguments to particular environments.
> Every element of the list has the form (NAME . SKEL-ELEM) where NAME is
> the name of the environment and SKEL-ELEM is an element to use in
> a skeleton (see `skeleton-insert')."
>   :type '(repeat (group (string :tag "Environment")
>                       (menu-choice
>                        :tag "Interactor"
>                        (const :tag "None" nil)
>                        (string :tag "Prompt")
>                        (repeat (string :tag "Prompt"))
>                        (sexp :tag "Expression"))
>                       (repeat
>                        :tag "Elements"
>                        :inline t
>                        (menu-choice
>                         :tag "Element"
>                         string
>                         character
>                         (const :tag "Indent" >)
>                         (const :tag "Newline" \n)
>                         (const :tag "Place point and region" _)
>                         (const :tag "Place point" -)
>                         (const :tag "Remembered location" @)
>                         (list :tag "Side effecting expression"
>                               (const :format "" quote) 
>                               (sexp :format "%v"))
>                         (sexp :tag "Expression"))))))

You've significantly changed it.  The use of `group' rather than `cons'
at the toplevel prevents me from generalizing the type to understand cases
such as ("myenv" . nil) or ("myenv" . some-var).

But if I understand correctly, the main trick you pulled is
to use :inline instead of ":format "%v%i".  This seems to work
around the misalignment problem.

As for the misalignment, I think what is going on is the following:
The top-level list does something like [warning: elisp-like pseudo-code
ahead]:

    (defun custom-insert-list (list)
      (while format
        (cond
          ((string-match "\\`%v\\(.*\\)" format)
            (dolist (elem elems)
            (insert-char ?\ <indent-amount>)
            (custom-insert-elem elem)
            (setq format (substring format 2)))
          ((string-match "\\`%v\\(.*\\)" format)
            (insert tag)
            (setq format (substring format 2)))
          ((string-match "\\`[^%]+" format)
           (insert (string-match 0 format))
           (setq format (substring format (match-end 0)))))))

Now if one elem is itself a list and if that elem's format starts
with "%v" we end up doing (insert-char ?\ <indent-amount>) twice
in a row for the first element of the sublist.

Of course, the <indent-amount> might not be the same for the list
and for the sublist.  I don't understand how this <indent-amount>
is set, BTW, so I'm not sure what should happen.  Any hint as to where
in the code its default value is maintained would be appreciated.

Maybe if we could document the "indentation invariant" (something like
"every widget printer is called with point in column <indent-amount>")
we could start figuring out where to fix things.



        Stefan





reply via email to

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