On Fri, 24 Oct 2008, Marcin Borkowski wrote:

> > > * Unlike when editing LaTeX files, it does not insert an \item when
> > >   doing C-c C-e itemize.  I use itemizations a lot and this is a bit
> > >   annoying, especially that I got used to its behaior when doing LaTeX.
> > >   Also, having C-c C-j asking about the (optional) label all the time is
> > >   also tiring, I would prefer to be asked for it only with C-u C-c C-j.
> > 
> > This is also annoying to me. I'll try to solve this, should no be too
> > complicated I think (only problem I have, is no spare time, just like
> > you...).
> 
> That would be great, also from the point of view of learning elisp...

Hello,

Here some code that you can attach to your .emacs file (just a copy from
auctex with minor modifications):

(require 'context-en)

(defun ConTeXt-en-mode-initialization ()
  "ConTeXt english interface specific initialization."
  (mapcar 'ConTeXt-add-environments (reverse ConTeXt-environment-list-en))
  (TeX-add-symbols
   '("but" ConTeXt-arg-define-ref (TeX-arg-literal " "))
   '("item" (TeX-arg-literal " "))
   '("items" [ConTeXt-arg-setup] (TeX-arg-string "Comma separated list"))
   '("its" ConTeXt-arg-define-ref (TeX-arg-literal " "))
   '("nop" (TeX-arg-literal " "))
   '("ran" TeX-arg-string (TeX-arg-literal " "))
   '("sub" ConTeXt-arg-define-ref (TeX-arg-literal " "))
   '("sym" (TeX-arg-string "Symbol") (TeX-arg-literal " "))))

(defun ConTeXt-insert-environment (environment &optional extra)
  "Insert ENVIRONMENT, with optional argument EXTRA."
  (if (and (TeX-active-mark)
           (not (eq (mark) (point))))
      (save-excursion
        (if (< (mark) (point))
            (exchange-point-and-mark))
        (insert TeX-esc (ConTeXt-environment-start-name) environment)
        (newline)
        (forward-line -1)
        (indent-according-to-mode)
        (if extra (insert extra))
        (goto-char (mark))
        (or (TeX-looking-at-backward "^[ \t]*")
            (newline))
        (insert TeX-esc (ConTeXt-environment-stop-name) environment)
        (newline)
        (forward-line -1)
        (indent-according-to-mode)
        ;;(goto-char (point))
        )
    (or (TeX-looking-at-backward "^[ \t]*")
        (newline))
    (insert TeX-esc (ConTeXt-environment-start-name) environment)
    (indent-according-to-mode)
    (if extra (insert extra))
    (end-of-line)
    (newline-and-indent)
        (if (string-equal environment "itemize")
                (ConTeXt-insert-item))
    (newline)
    (insert TeX-esc (ConTeXt-environment-stop-name) environment)
    (or (looking-at "[ \t]*$")
        (save-excursion (newline-and-indent)))
    (indent-according-to-mode)
    (end-of-line 0)))

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to