home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / emacs / help / 3521 < prev    next >
Encoding:
Text File  |  1992-07-27  |  1.7 KB  |  40 lines

  1. Organization: Carnegie Mellon, Pittsburgh, PA
  2. Path: sparky!uunet!cis.ohio-state.edu!news.sei.cmu.edu!fs7.ece.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!jf41+
  3. Newsgroups: gnu.emacs.help
  4. Message-ID: <8eRCDdO00VpA4D6Rgt@andrew.cmu.edu>
  5. Date: Tue, 28 Jul 1992 02:06:33 -0400 
  6. From: "Jonathan R. Ferro" <jf41+@andrew.cmu.edu>
  7. Subject: 2 Elisp questions
  8. Lines: 30
  9.  
  10. In the process of writing some functions that did some file munching I
  11. wanted to find out if a file had been loaded into an emacs buffer or
  12. not and came up with this doozy:
  13.  
  14.   (let* ((expanded-name (expand-file-name file))
  15.          (already-found
  16.           ;; ARGH!  Can't apply "or" over truth-values because it's a
  17.           ;; special form.  Have to convert back and forth from tv's
  18.           ;; to ints so "logior" can be used.  Grrn.
  19.           (= 1 (apply 'logior
  20.                       (mapcar '(lambda (buf)
  21.                                  (if (string-equal (buffer-file-name buf)
  22.                                                    expanded-name)
  23.                                      1 0))                          
  24.                               (buffer-list))))))
  25.     ...
  26.  
  27. 1. Is there a better way to find out if a file is being visited?
  28.    Did I miss a function in the manual?
  29.    Should I consider "remember length of (buffer-list), find the file, 
  30.     see if length changed"?
  31.  
  32. 2. Is there REALLY no built-in function that you can apply to a list of
  33.    t's and nil's to get their collective AND or OR?  I eventually broke
  34.    down and wrote my own, but this is surprising.
  35.  
  36. --
  37. Jon Ferro        MIT Transportation Modelling Research Center (TMRC)
  38. jf41+@andrew.cmu.edu    "We can hack it!"
  39. SGNTR VRS VRSN 3.1B: Strppd nd cmprssd fr qckr trnsmssn! nfct yrs tdy!
  40.