🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #188793

Re: next-line question

#188793
From: Bill Wohler
Date: Wed, 10 Jul 1991 15:42
39 lines
1901 bytes
  the other suggestions were nice, but here is a replacement for
  next-line that was posted by rms a few years back for comments.
  there is only a one line change.  i don't know why it never became
  part of the code--it makes much more sense than the default
  behavior.


(defun next-line (arg)
  "Move cursor vertically down ARG lines.
If there is no character in the target line exactly under the current column,
the cursor is positioned after the character in that line which spans this
column, or at the end of the line if it is not long enough.
If there is no line in the buffer after this one,
a newline character is inserted to create a line
and the cursor moves to that line.

The command \\[set-goal-column] can be used to create
a semipermanent goal column to which this command always moves.
Then it does not try to move vertically.

If you are thinking of using this in a Lisp program, consider
using `forward-line' instead.  It is usually easier to use
and more reliable (no dependence on goal column, etc.)."
  (interactive "p")
  (if (= arg 1)
      (let ((opoint (point)))
	(forward-line 1)
	(if (not (eq (preceding-char) ?\n))
	    (insert ?\n)
	  (goto-char opoint)
	  (next-line-internal arg)))
    (next-line-internal arg))
  nil)
-- 
						--bw
-----
Bill Wohler <wohler@sap-ag.de> <sapwdf!wohler>
Heidelberg Red Barons Ultimate Frisbee Team
Technical Details
Message-ID: <2926@sapwdf.UUCP>
Path: arc1-ca.pugleaf.net!gmdzi!unido!sapwdf!wohler
References: <3845@charon.cwi.nl>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 103b8b,b8a9d8f033088283
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1991-07-10 10:32:30 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!sapwdf!wohler
From: wohler@sapwdf.UUCP (Bill Wohler)
Newsgroups: gnu.emacs.help
Subject: Re: next-line question
Message-ID: <2926@sapwdf.UUCP>
Date: 10 Jul 91 15:42:16 GMT
References: <3845@charon.cwi.nl>
Reply-To: Bill Wohler <wohler@sap-ag.de>
Organization: SAP AG, Walldorf, Germany
Lines: 39