🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #188788

Re: next-line question

#188788
From: Eric Eide
Date: Tue, 09 Jul 1991 17:50
41 lines
2464 bytes
>In article <3845@charon.cwi.nl> waal@cwi.nl (Peter de Waal) writes:
>>
>>    (defun my-next-line (arg)
>>      "doesn't next-line past end of buffer"
>>      (interactive "p")
>>      (if (not (eobp)) (next-line arg)))
>>
>>as an alternative for the standard 'next-line'. It has the advantage
>>that it doesn't add new lines at the end of a buffer. The disadvantage
>>is that is forgets the original column position of the cursor [...]
>
>This is "expensive", but works. I'd like a "cheaper" way, but I'm sure
>one will show up ... [... expensive function deleted]

Here's mine.  Nice and cheap, and it doesn't forget which column you're at.

(defun next-line-until-eob (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 charactre in that line which spans this
column, or at the end of the line if it is not long enough.

Unlike next-line, this command will not insert newlines.

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")
  (setq this-command 'next-line) ;; Fool line-move; see simple.el.
  (line-move arg))

If you're using GNU Emacs 18.56 or later, change "line-move" to
"next-line-internal".

-------------------------------------------------------------------------------
Eric Eide          |          University of Utah Department of Computer Science
eeide@cs.utah.edu  | Buddhist to hot dog vendor: "Make me one with everything."
Technical Details
Message-ID: <EEIDE.91Jul9125031@asylum.utah.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!caen!hellgate.utah.edu!eeide
References: <3845@charon.cwi.nl> <1991Jul9.172453.26795@beaver.cs.washington.edu>

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-09 15:24:35 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!caen!hellgate.utah.edu!eeide
From: eeide%asylum.utah.edu@cs.utah.edu (Eric Eide)
Newsgroups: gnu.emacs.help
Subject: Re: next-line question
Message-ID: <EEIDE.91Jul9125031@asylum.utah.edu>
Date: 9 Jul 91 17:50:31 GMT
References: <3845@charon.cwi.nl>
 <1991Jul9.172453.26795@beaver.cs.washington.edu>
Organization: /u/grad/eeide/.organization
Lines: 41
In-reply-to: pauld@stowe.cs.washington.edu's message of Tue, 9 Jul 91 17:24:53 GMT