home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / emacs / help / 4065 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.5 KB  |  45 lines

  1. Newsgroups: gnu.emacs.help
  2. Path: sparky!uunet!usc!cs.utexas.edu!torn!cunews!nrcnet0!bnrgate!bmerh85!bmerh85!hamish
  3. From: Hamish.Macdonald@x400gate.bnr.ca (Hamish Macdonald)
  4. Subject: Re: Equivalents to vi's H, M, L Commands?
  5. In-Reply-To: Hamish.Macdonald@x400gate.bnr.ca's message of Wed, 09 Sep 92 19:28:05 GMT
  6. Message-ID: <1992Sep10.135545.26512@bmerh85.bnr.ca>
  7. Lines: 32
  8. Sender: news@bmerh85.bnr.ca (Usenet News)
  9. Organization: Bell Northern Research
  10. References: <1992Sep09.183531.5615@bnr.ca> <1992Sep09.192805.12394@bmerh85.bnr.ca>
  11. Date: Thu, 10 Sep 92 13:55:45 GMT
  12.  
  13. >>>>> On Wed, 09 Sep 92 19:28:05 GMT,
  14. >>>>> In message <1992Sep09.192805.12394@bmerh85.bnr.ca>,
  15. >>>>> I wrote:
  16.  
  17. [some top-of-window, middle-of-window, and bottom-of-window functions
  18.  which won't work in emacs 18.58 for one thing, and are buggy to boot]
  19.  
  20. It seems that the "window-end" I used is from Lucid Emacs 19, and not
  21. available in emacs 18.
  22.  
  23. Here is a replacement which seems to work:
  24.  
  25. (defun window-end (&optional window)
  26.   "Return position at which display currently ends in WINDOW."
  27.   (save-excursion
  28.     (goto-char (window-start window))
  29.     (forward-line (- (window-height window) 2))
  30.     (end-of-line)
  31.     (point)))
  32.  
  33. Also, the middle-of-window function only works if the top of the
  34. window is the beginning of the buffer :-)
  35.  
  36. Here is one which seems to work:
  37.  
  38. (defun middle-of-window()
  39.     "Go to middle line of window"
  40.     (interactive)
  41.     (goto-char (+ (window-start) (/ (- (window-end) (window-start)) 2)))
  42.     (beginning-of-line))
  43.  
  44. No warranty.
  45.