unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: need help with emacs
Date: Fri, 07 Jan 2005 17:41:18 GMT	[thread overview]
Message-ID: <jwvu0ptjh4t.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: 1105074884.110660@sj-nntpcache-3

> 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

      reply	other threads:[~2005-01-07 17:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-07  5:09 need help with emacs Zia Mulla
2005-01-07 17:41 ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvu0ptjh4t.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).