home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / religion / emacs / 468 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  2.1 KB

  1. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!swrinde!news.dell.com!texsun!digi!kgallagh
  2. From: kgallagh@digi.lonestar.org (Kevin Gallagher)
  3. Newsgroups: alt.religion.emacs
  4. Subject: Re: What does (point) point at?
  5. Message-ID: <1992Nov22.215430.3176@digi.lonestar.org>
  6. Date: 22 Nov 92 21:54:30 GMT
  7. References: <DOOM.92Nov21200251@elaine6.Stanford.EDU>
  8. Distribution: alt
  9. Organization: DSC Communications Corp, Plano, TX
  10. Lines: 34
  11.  
  12. In article <DOOM.92Nov21200251@elaine6.Stanford.EDU> doom@elaine6.Stanford.EDU (Joseph Brenner) writes:
  13. >In emacs lisp, you can evaluate (point) to find out where
  14. >the point is.  How do you find out what is at this point in
  15. >the file?  For example, I might want to do one thing if the
  16. >cursor is on some white space, and another thing if it's on
  17. >a character, but I can only think of the most kludgy ways of
  18. >checking which is the case. 
  19. >
  20. >(How's this: put the cursor somewhere.  Record the location.
  21. >Do a search for a space.  Compare location to the recorded
  22. >location.  If the location has changed, you know it wasn't a
  23. >space.  
  24. >
  25. >There's gotta be a better way.) 
  26.  
  27. Without moving point, the following code tests if the character following
  28. point is a white space, according to the definition of white space in the
  29. syntax table.
  30.  
  31.         (eq ?\  (char-syntax (following-char))
  32.  
  33. Note, there are 2 blanks after the back slash character.  (For more
  34. information, check out Chapter 30, Syntax Tables, in the GNU Emacs Lisp
  35. Reference Manual, Edition 1.03.)
  36.  
  37. From a programming view, point always lies BETWEEN two characters, while the
  38. cursor lies on top of the character immediately following point.  (This is all
  39. explained in section 1.1, Point, of the GNU Emacs Manual.)  Thus, the function
  40. "following-char" returns the character under the cursor.
  41. -- 
  42. ----------------------------------------------------------------------------
  43. Kevin Gallagher        kgallagh@digi.lonestar.org OR ...!uunet!digi!kgallagh
  44. DSC Communications Corporation   Addr: MS 152, 1000 Coit Rd, Plano, TX 75075
  45. ----------------------------------------------------------------------------
  46.