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

Re: Speaking of Syntax



    Date: Mon, 16 Nov 87 08:46 CET
    From: "Heinz W. Schmidt" <unido!gmdzi!LISPM-2!hws@uunet.UU.NET>

	  >That won't work in Rel 7 -- a hash table is now used once the editor
	  >is built.

    It seems (zwei:defindentation ... ) is the official way in Rel 7 to obtain
    the behaviour I described for OFFSET-LISTs.
    Does defindentation or another official def also support 
    user indentation functions?
     like, say,  (zwei:defindentation (my-def  #'indent-my-def)) 
	   or    (zwei:defindentation (my-def  indent-my-def)))

    - hws

Something close to what you want is zwei::*indent-new-line-indent-function*; I
had to patch a couple commands (e.g. com-indent-new-comment-line) to obey it,
but it is obeyed in com-indent-new-line. I suspect I would be violating some
agreement if I sent you code, but basically, look at the defn of
com-indent-new-line, and try setting the function to something like this
(which I use for TeX mode):

(DEFUN TEX-NEW-LINE-INDENTER ()
  "Indents new lines. This just does a TAB, unless prev. line flush."
  (LET ((PT (POINT)))
    (DO	((LINE (BP-LINE PT))
	 (LIMIT-LINE (BP-LINE (INTERVAL-FIRST-BP *INTERVAL*))))
	((EQ LINE LIMIT-LINE)
	 (RETURN-FROM TEX-NEW-LINE-INDENTER DIS-NONE))
      (SETQ LINE (LINE-PREVIOUS-IN-BUFFER LINE))
      (COND ((NOT (LINE-BLANK-P LINE))
	     ;; We have found a non-blank line.
	     (RETURN-FROM TEX-NEW-LINE-INDENTER
	       (COND ((ZEROP (LINE-INDENTATION LINE))
		      ;; it's unindented, do nothing
		      DIS-NONE)
		     (T
		      ;; insert a tab
		      (KEY-EXECUTE #\TAB)))))))))

This is just an example of the sort of thing you might try binding to this
var. There's no real doc on this, I just looked at the newline code and
guessed what would be appropriate. It's certainly handy though, as you
probably guessed by asking the question.

Luck,
Brad Miller
------
miller@cs.rochester.edu {...allegra!rochester!miller}
Brad Miller
University of Rochester Computer Science Department