unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* need help with emacs
@ 2005-01-07  5:09 Zia Mulla
  2005-01-07 17:41 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Zia Mulla @ 2005-01-07  5:09 UTC (permalink / raw)


Hi all,

I am using TCL in EMACS. What I need right now is the ability to do newline
and indent on a line exceeding 80 characters in addition to adding a \.
e.g.

Suppose I type a line:
This is just an example for lisp in EMACS. This is an example for lisp in
EMACS. This is an example.

This line should be indented as follows:

This is just an example for lisp in EMACS. This is an example for lisp in \
    EMACS. This is an example.

I am not sure if this can be achieved using auto-fill-mode. Maybe someone
among you might be using this or have any idea.

Thanks
Zia

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

* Re: need help with emacs
  2005-01-07  5:09 need help with emacs Zia Mulla
@ 2005-01-07 17:41 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2005-01-07 17:41 UTC (permalink / raw)


> I am using TCL in EMACS. What I need right now is the ability to do newline
> and indent on a line exceeding 80 characters in addition to adding a \.
> e.g.

> Suppose I type a line:
> This is just an example for lisp in EMACS. This is an example for lisp in
> EMACS. This is an example.

> This line should be indented as follows:

> This is just an example for lisp in EMACS. This is an example for lisp in \
>     EMACS. This is an example.

> I am not sure if this can be achieved using auto-fill-mode. Maybe someone
> among you might be using this or have any idea.

You can probably get auto-fill-mode to do something like what you want.
You'll probably need something like:

   (defun my-tcl-comment-line-break-function (&optional soft)
     (if (tcl-in-string-p) (insert "\\"))
     (comment-indent-new-line soft))

   (defun my-tcl-mode-hook ()
     ...your other Tcl-mode customizations here...
     (set (make-local-variable 'comment-line-break-function)
          'my-tcl-comment-line-break-function))

   (add-hook 'tcl-mode-hook 'my-tcl-mode-hook)

But tcl-mode does not define tcl-in-string-p.  If you use Emacs-CVS (and
font-lock), you can try to use

    (defun tcl-in-string-p () (nth 3 (syntax-ppss)))

if not, you can try

    (defun tcl-in-string-p ()
      (nth 3 (parse-partial-sexp (point-min) (point))))

but that may end up being too slow if you're editing a large Tcl buffer
(syntax-ppss is much faster because it uses caching).

Another option is something like

    (defun tcl-in-string-p ()
      (save-excursion
        (let ((pos (point)))
          (beginning-of-defun)
          (nth 3 (parse-partial-sexp (point) pos)))))

which should stay reasonably fast.


        Stefan

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

end of thread, other threads:[~2005-01-07 17:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-07  5:09 need help with emacs Zia Mulla
2005-01-07 17:41 ` Stefan Monnier

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).