Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mgm.mit.edu!wolfgang From: wolfgang@mgm.mit.edu (Wolfgang Rupprecht) Newsgroups: comp.emacs Subject: Re: GNU 18.49 elisp question Message-ID: <3507@bloom-beacon.MIT.EDU> Date: 5 Mar 88 21:33:05 GMT References: <6878@drutx.ATT.COM> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: wolfgang@mgm.mit.edu (Wolfgang Rupprecht) Organization: Freelance Software Consultant, Boston, Ma. Lines: 51 In article <6878@drutx.ATT.COM> jimb@drutx.ATT.COM (jim bryant) writes: >i'm trying to write a simple function that will set "fill-prefix" >before calling "fill-region". for example ># this is the comment block ># that i would like to fill ># it probably would fit on 2 lines Ok, I'll bite. Here is a slightly rearranged version of your code, with the ????'s filled in. # this is the comment block that i would like to fill it probably # would fit on 2 lines (defun fill-unix-comment-block () "How about some snazzy documentation string here." (interactive) (save-excursion (beginning-of-line) (if (looking-at "#") (progn (forward-char 1) (skip-chars-forward " \t") (let ((fill-prefix)) ;don't trash the real fill-prefix! (set-fill-prefix) (fill-paragraph nil))) (fill-paragraph nil)))) ; With a bit more work, you could make the fill-prefix detection much ; more general, and not hardwire the "^#[ \t]*" regexp into the code. (defvar fill-comment-block-regexp "^a-zA-Z0-9" "*Regexp to identify the fill-prefix for the fill-comment-block function.") (defun fill-comment-block () "Fill a comment block. Uses fill-comment-block-regexp to identify the fill-prefix. If none found, uses the default fill-prefix." (interactive) (save-excursion (beginning-of-line) (if (looking-at (concat "[" fill-comment-block-regexp "]")) (progn (skip-chars-forward fill-comment-block-regexp) (let ((fill-prefix)) (set-fill-prefix) (fill-paragraph nil))) (fill-paragraph nil)))) --- Wolfgang Rupprecht ARPA: wolfgang@mgm.mit.edu (IP 18.82.0.114) 326 Commonwealth Ave. UUCP: mit-eddie!mgm.mit.edu!wolfgang Boston, Ma. 02115 TEL: (617) 267-4365