aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-09-02 01:18:35 +0000
committerRichard M. Stallman1996-09-02 01:18:35 +0000
commitaeafca1f94ff8146308b89a8e1a5ff865f6fce76 (patch)
treebf3103b5128088aa507f5a83f394089a2d358fec
parent9dc176a0123c924a2aa2f065b563ee2833fe7c95 (diff)
downloademacs-aeafca1f94ff8146308b89a8e1a5ff865f6fce76.tar.gz
emacs-aeafca1f94ff8146308b89a8e1a5ff865f6fce76.zip
(ffap-locate-file): Function deleted.
(ffap-locate-jka-suffixes): Variable deleted. (ffap-alist): Use locate-library.
-rw-r--r--lisp/ffap.el80
1 files changed, 11 insertions, 69 deletions
diff --git a/lisp/ffap.el b/lisp/ffap.el
index 2ce98117774..671e0eddb65 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -559,70 +559,12 @@ Uses `path-separator' to separate the path into directories."
559 path (cdr path))) 559 path (cdr path)))
560 (nreverse ret))) 560 (nreverse ret)))
561 561
562(defvar ffap-locate-jka-suffixes t
563 "List of compression suffixes tried by `ffap-locate-file'.
564If not a list, it is initialized by `ffap-locate-file',
565and it becomes nil unless you are using jka-compr.
566Typical values are nil or '(\".gz\" \".z\" \".Z\").")
567
568(defun ffap-locate-file (file &optional nosuffix path)
569 "A generic path-searching function, mimics `load' by default.
570Returns path to file that \(load FILE\) would load, or nil.
571Optional NOSUFFIX, if nil or t, is like the fourth argument
572for load: whether to try the suffixes (\".elc\" \".el\" \"\").
573If a nonempty list, it is a list of suffixes to try instead.
574Optional PATH is a list of directories instead of `load-path'."
575 (or path (setq path load-path))
576 (if (file-name-absolute-p file)
577 (setq path (list (file-name-directory file))
578 file (file-name-nondirectory file)))
579 (let ((suffixes-to-try
580 (cond
581 ((consp nosuffix) nosuffix)
582 (nosuffix '(""))
583 (t '(".elc" ".el" "")))))
584 ;; Modern (>19.27) jka-compr doesn't try foo.gz when you want foo.
585 (or (listp ffap-locate-jka-suffixes)
586 (setq ffap-locate-jka-suffixes
587 (and (featurep 'jka-compr)
588 (not (featurep 'jka-aux))
589 jka-compr-file-name-handler-entry
590 (not (string-match
591 (car jka-compr-file-name-handler-entry)
592 "foo"))
593 ;; Hard to do this cleverly across jka-compr versions:
594 '(".gz" ".Z"))))
595 (if ffap-locate-jka-suffixes ; so nil behaves like '("")
596 (setq suffixes-to-try
597 (apply
598 'nconc
599 (mapcar
600 (function
601 (lambda (suf)
602 (cons suf
603 (mapcar
604 (function (lambda (x) (concat suf x)))
605 ffap-locate-jka-suffixes))))
606 suffixes-to-try))))
607 (let (found suffixes)
608 (while (and path (not found))
609 (setq suffixes suffixes-to-try)
610 (while (and suffixes (not found))
611 (let ((try (expand-file-name
612 (concat file (car suffixes))
613 (car path))))
614 (if (and (file-exists-p try) (not (file-directory-p try)))
615 (setq found try)))
616 (setq suffixes (cdr suffixes)))
617 (setq path (cdr path)))
618 found)))
619
620(defvar ffap-alist 562(defvar ffap-alist
621 ;; A big mess! Parts are probably useless. 563 ;; A big mess! Parts are probably useless.
622 (list 564 (list
623 (cons "\\.info\\'" 565 (cons "\\.info\\'"
624 (defun ffap-info (name) 566 (defun ffap-info (name)
625 (ffap-locate-file 567 (locate-library
626 name '("" ".info") 568 name '("" ".info")
627 (or (ffap-soft-value "Info-directory-list") 569 (or (ffap-soft-value "Info-directory-list")
628 (ffap-soft-value "Info-default-directory-list") 570 (ffap-soft-value "Info-default-directory-list")
@@ -636,13 +578,13 @@ Optional PATH is a list of directories instead of `load-path'."
636 (defun ffap-info-3 (name) 578 (defun ffap-info-3 (name)
637 (and (equal (ffap-string-around) "()") (ffap-info name)))) 579 (and (equal (ffap-string-around) "()") (ffap-info name))))
638 (cons "\\.elc?\\'" 580 (cons "\\.elc?\\'"
639 (defun ffap-el (name) (ffap-locate-file name t))) 581 (defun ffap-el (name) (locate-library name t)))
640 (cons 'emacs-lisp-mode 582 (cons 'emacs-lisp-mode
641 (defun ffap-el-mode (name) 583 (defun ffap-el-mode (name)
642 ;; We do not bother with "" here, since it was considered above. 584 ;; We do not bother with "" here, since it was considered above.
643 ;; Also ignore "elc", for speed (who else reads elc files?) 585 ;; Also ignore "elc", for speed (who else reads elc files?)
644 (and (not (string-match "\\.el\\'" name)) 586 (and (not (string-match "\\.el\\'" name))
645 (ffap-locate-file name '(".el"))))) 587 (locate-library name '(".el")))))
646 '(finder-mode . ffap-el-mode) ; v19: {C-h p} 588 '(finder-mode . ffap-el-mode) ; v19: {C-h p}
647 '(help-mode . ffap-el-mode) ; v19.29 589 '(help-mode . ffap-el-mode) ; v19.29
648 (cons 'c-mode 590 (cons 'c-mode
@@ -650,7 +592,7 @@ Optional PATH is a list of directories instead of `load-path'."
650 ;; Need better defaults here! 592 ;; Need better defaults here!
651 (defvar ffap-c-path '("/usr/include" "/usr/local/include")) 593 (defvar ffap-c-path '("/usr/include" "/usr/local/include"))
652 (defun ffap-c-mode (name) 594 (defun ffap-c-mode (name)
653 (ffap-locate-file name t ffap-c-path)))) 595 (locate-library name t ffap-c-path))))
654 '(c++-mode . ffap-c-mode) 596 '(c++-mode . ffap-c-mode)
655 '(cc-mode . ffap-c-mode) 597 '(cc-mode . ffap-c-mode)
656 '("\\.\\([chCH]\\|cc\\|hh\\)\\'" . ffap-c-mode) 598 '("\\.\\([chCH]\\|cc\\|hh\\)\\'" . ffap-c-mode)
@@ -680,20 +622,20 @@ If t, `ffap-tex-init' will initialize this when needed.")
680 )))))))) 622 ))))))))
681 (defun ffap-tex-mode (name) 623 (defun ffap-tex-mode (name)
682 (ffap-tex-init) 624 (ffap-tex-init)
683 (ffap-locate-file name '(".tex" "") ffap-tex-path)))) 625 (locate-library name '(".tex" "") ffap-tex-path))))
684 (cons 'latex-mode 626 (cons 'latex-mode
685 (defun ffap-latex-mode (name) 627 (defun ffap-latex-mode (name)
686 (ffap-tex-init) 628 (ffap-tex-init)
687 ;; Any real need for "" here? 629 ;; Any real need for "" here?
688 (ffap-locate-file name '(".cls" ".sty" ".tex" "") 630 (locate-library name '(".cls" ".sty" ".tex" "")
689 ffap-tex-path))) 631 ffap-tex-path)))
690 (cons "\\.\\(tex\\|sty\\|doc\\|cls\\)\\'" 632 (cons "\\.\\(tex\\|sty\\|doc\\|cls\\)\\'"
691 (defun ffap-tex (name) 633 (defun ffap-tex (name)
692 (ffap-tex-init) 634 (ffap-tex-init)
693 (ffap-locate-file name t ffap-tex-path))) 635 (locate-library name t ffap-tex-path)))
694 (cons "\\.bib\\'" 636 (cons "\\.bib\\'"
695 (defun ffap-bib (name) 637 (defun ffap-bib (name)
696 (ffap-locate-file 638 (locate-library
697 name t 639 name t
698 (ffap-list-env "BIBINPUTS" '("/usr/local/lib/tex/macros/bib"))))) 640 (ffap-list-env "BIBINPUTS" '("/usr/local/lib/tex/macros/bib")))))
699 (cons 'math-mode 641 (cons 'math-mode
@@ -702,9 +644,9 @@ If t, `ffap-tex-init' will initialize this when needed.")
702 (setq name (concat (substring name 0 (match-beginning 0)) 644 (setq name (concat (substring name 0 (match-beginning 0))
703 "/" 645 "/"
704 (substring name (match-end 0))))) 646 (substring name (match-end 0)))))
705 (ffap-locate-file 647 (locate-library
706 name '(".m" "") (ffap-soft-value "Mathematica-search-path")))) 648 name '(".m" "") (ffap-soft-value "Mathematica-search-path"))))
707 (cons "\\`\\." (defun ffap-home (name) (ffap-locate-file name t '("~")))) 649 (cons "\\`\\." (defun ffap-home (name) (locate-library name t '("~"))))
708 (cons "\\`~/" 650 (cons "\\`~/"
709 ;; Maybe a "Lisp Code Directory" reference: 651 ;; Maybe a "Lisp Code Directory" reference:
710 (defun ffap-lcd (name) 652 (defun ffap-lcd (name)