home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!elroy.jpl.nasa.gov!ucla-cs!twinsun!usenet
- From: sdk@shadow.twinsun.com (Scott D Kalter)
- Newsgroups: gnu.emacs.help
- Subject: Re: question on universal-argument or C-u
- Message-ID: <biNj#doJ@twinsun.com>
- Date: 21 Jul 92 16:14:34 GMT
- References: <1992Jul16.193150.5172@Warren.MENTORG.COM>
- Sender: usenet@twinsun.com
- Organization: Twin Sun, Inc.
- Lines: 37
- In-Reply-To: sharma@euler.Warren.MENTORG.COM's message of Thu, 16 Jul 1992 19:31:50 GMT
- Nntp-Posting-Host: shadow
-
- In article <1992Jul16.193150.5172@Warren.MENTORG.COM> sharma@euler.Warren.MENTORG.COM (Sharma Kunapalli) writes:
-
- -> I have defined rathed defun'ed :-) a function in
- -> emacs lisp. Call that function f. Now I want to
- -> write another function which will call this function
- -> a certain number of times equal to the number of lines
- -> in the buffer.
- ->
- -> (defun f ()
- -> (re-search-forward "^#" nil)
- -> (beginning-of-line)
- -> (kill-line)
- -> (kill-line))
- ->
- -> (defun my-rep ()
- -> (interactive)
- -> (universal-argument 4 (next-line)))
- ->
-
- First, a reasonable way of finding the number of lines in a buffer is:
-
- (count-lines (point-min) (point-max))
-
- Second, a reasonable way of attacking the original problem (assuming
- the intent is to remove all lines starting with '#' from a buffer) is
- to use the regular expression facilities in emacs:
-
- (defun f ()
- (save-excursion
- (goto-char (point-min))
- (replace-regexp "^#.*\n" "")))
-
-
-
- Hope this helps,
-
- -sdk
-