Article View: gnu.epoch.misc
Article #806Re: Looking for some epoch code
From: Mark D. Baushke
Date: Tue, 10 Aug 1993 20:40
Date: Tue, 10 Aug 1993 20:40
91 lines
3863 bytes
3863 bytes
On Tue, 10 Aug 93 13:57:20 GMT, drp@dvorak.amd.com (Doug Puchalski) said:
doug> I'm looking for lisp code that
doug> - Shows line & col when I click the mouse
I don't have one off hand, but you should be able to bind the mouse to
do a (what-cursor-position) for you.
doug> - Won't let me add lines to the end of a file with the down arrow
See next-line-noextend.el after my .signature (it works for emacs
18.55 through 18.59 and all versions of epoch).
doug> Can someone post it?
-- Mark
mdb@cisco.com
;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
;; next-line-noextend.el --- do not let C-n add lines to a file
;;
;; Author : Mark D. Baushke
;; Created On : Mon Mar 6 14:13:27 1989
;; Last Modified By: Mark D. Baushke
;; Last Modified On: Thu May 24 23:49:11 1990
;; Update Count : 2
;; Status : Works for me with GNU Emacs 18.55
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Ever feel like not adding lots of blank lines to the end of a file?
;;
(defun next-line-noextend (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 and the last line
does not end in a newline character,
a newline character is inserted to create a line
and the cursor moves to that line.
Otherwise, a warning message is generated.
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)
(if (= opoint (point))
(progn
(beep)
(message "End of buffer"))
(goto-char opoint)
(line-move arg))))
(line-move arg))
nil)
(substitute-key-definition 'next-line 'next-line-noextend global-map)
(substitute-key-definition 'next-line 'next-line-noextend esc-map)
(substitute-key-definition 'next-line 'next-line-noextend ctl-x-map)
(defun line-move (arg)
(if (not (or (eq last-command 'next-line)
(eq last-command 'next-line-noextend)
(eq last-command 'previous-line)))
(setq temporary-goal-column
(if (and track-eol (eolp))
9999
(current-column))))
(if (not (integerp selective-display))
(forward-line arg)
;; Move by arg lines, but ignore invisible ones.
(while (> arg 0)
(vertical-motion 1)
(forward-char -1)
(forward-line 1)
(setq arg (1- arg)))
(while (< arg 0)
(vertical-motion -1)
(beginning-of-line)
(setq arg (1+ arg))))
(move-to-column (or goal-column temporary-goal-column))
nil)
Technical Details
Message-ID:
<199308101830.AA12151@glare.cisco.com>Path:
arc1-ca.pugleaf.net!gmd.de!xlink.net!math.fu-berlin.de!news.dfn.de!darwin.sura.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!cisco.com!mdbReferences:
<1993Aug10.135720.23648@dvorak.amd.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,c38e7c21a348fc3c X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1993-08-10 14:25:25 PST Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!math.fu-berlin.de!news.dfn.de!darwin.sura.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!cisco.com!mdb From: mdb@cisco.com (Mark D. Baushke) Newsgroups: gnu.epoch.misc Subject: Re: Looking for some epoch code Date: 10 Aug 1993 16:40:45 -0400 Organization: cisco Systems Inc., Menlo Park, CA, USA Lines: 91 Sender: daemon@cis.ohio-state.edu Distribution: gnu Message-ID: <199308101830.AA12151@glare.cisco.com> References: <1993Aug10.135720.23648@dvorak.amd.com>