Mercurial > emacs
comparison lisp/find-file.el @ 49588:37645a051842
Trailing whitespace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 11:26:42 +0000 |
parents | 8b3977d58df6 |
children | 0a061fbe2420 d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49587:e82b3fe06d4c | 49588:37645a051842 |
---|---|
68 ;; (setq cc-other-file-alist | 68 ;; (setq cc-other-file-alist |
69 ;; '(("\\.cc$" ff-cc-hh-converter) | 69 ;; '(("\\.cc$" ff-cc-hh-converter) |
70 ;; ("\\.hh$" ff-cc-hh-converter) | 70 ;; ("\\.hh$" ff-cc-hh-converter) |
71 ;; ("\\.c$" (".h")) | 71 ;; ("\\.c$" (".h")) |
72 ;; ("\\.h$" (".c" ".cc" ".C" ".CC" ".cxx" ".cpp")))) | 72 ;; ("\\.h$" (".c" ".cc" ".C" ".CC" ".cxx" ".cpp")))) |
73 ;; | 73 ;; |
74 ;; ff-cc-hh-converter is included at the end of this file as a reference. | 74 ;; ff-cc-hh-converter is included at the end of this file as a reference. |
75 ;; | 75 ;; |
76 ;; SEARCHING is carried out in a set of directories specified by the | 76 ;; SEARCHING is carried out in a set of directories specified by the |
77 ;; ff-search-directories variable: | 77 ;; ff-search-directories variable: |
78 ;; | 78 ;; |
79 ;; ("." "../../src" "../include/*" "/usr/local/*/src/*" "$PROJECT/src") | 79 ;; ("." "../../src" "../include/*" "/usr/local/*/src/*" "$PROJECT/src") |
80 ;; | 80 ;; |
498 (setq name | 498 (setq name |
499 (expand-file-name | 499 (expand-file-name |
500 (read-file-name | 500 (read-file-name |
501 (format "Find or create %s in: " default-name) | 501 (format "Find or create %s in: " default-name) |
502 default-directory default-name nil))) | 502 default-directory default-name nil))) |
503 | 503 |
504 (setq pathname | 504 (setq pathname |
505 (if (file-directory-p name) | 505 (if (file-directory-p name) |
506 (concat (file-name-as-directory name) default-name) | 506 (concat (file-name-as-directory name) default-name) |
507 (setq found name))) | 507 (setq found name))) |
508 | 508 |
509 (ff-find-file pathname in-other-window t))) | 509 (ff-find-file pathname in-other-window t))) |
510 | 510 |
511 (t ;; don't create the file, just whinge | 511 (t ;; don't create the file, just whinge |
512 (message "No file found for %s" fname)))) | 512 (message "No file found for %s" fname)))) |
513 | 513 |
617 "Find a file in the SEARCH-DIRS with the given FILENAME (or filename stub). | 617 "Find a file in the SEARCH-DIRS with the given FILENAME (or filename stub). |
618 If (optional) SUFFIX-LIST is nil, search for fname, otherwise search | 618 If (optional) SUFFIX-LIST is nil, search for fname, otherwise search |
619 for fname with each of the given suffixes. Get the file or the buffer | 619 for fname with each of the given suffixes. Get the file or the buffer |
620 corresponding to the name of the first file found, or nil." | 620 corresponding to the name of the first file found, or nil." |
621 (let ((filename (ff-get-file-name search-dirs filename suffix-list))) | 621 (let ((filename (ff-get-file-name search-dirs filename suffix-list))) |
622 | 622 |
623 (cond | 623 (cond |
624 ((not filename) | 624 ((not filename) |
625 nil) | 625 nil) |
626 | 626 |
627 ((bufferp (get-file-buffer filename)) | 627 ((bufferp (get-file-buffer filename)) |
628 (ff-switch-to-buffer (get-file-buffer filename) other-window) | 628 (ff-switch-to-buffer (get-file-buffer filename) other-window) |
629 filename) | 629 filename) |
630 | 630 |
631 ((file-exists-p filename) | 631 ((file-exists-p filename) |
632 (ff-find-file filename other-window nil) | 632 (ff-find-file filename other-window nil) |
633 filename) | 633 filename) |
634 | 634 |
635 (t | 635 (t |
657 ;; otherwise fname-stub is a stub, and we append a suffix | 657 ;; otherwise fname-stub is a stub, and we append a suffix |
658 (if suffixes | 658 (if suffixes |
659 (setq this-suffix (car suffixes)) | 659 (setq this-suffix (car suffixes)) |
660 (setq this-suffix "") | 660 (setq this-suffix "") |
661 (setq suffixes (list ""))) | 661 (setq suffixes (list ""))) |
662 | 662 |
663 ;; find whether the file is in a buffer first | 663 ;; find whether the file is in a buffer first |
664 (while (and suffixes (not found)) | 664 (while (and suffixes (not found)) |
665 (setq filename (concat fname-stub this-suffix)) | 665 (setq filename (concat fname-stub this-suffix)) |
666 | 666 |
667 (if (not ff-quiet-mode) | 667 (if (not ff-quiet-mode) |
691 (setq suffixes suffix-list) | 691 (setq suffixes suffix-list) |
692 | 692 |
693 ;; if dir does not contain '/*', look for the file | 693 ;; if dir does not contain '/*', look for the file |
694 (if (and dir (not (string-match "\\([^*]*\\)/\\\*\\(/.*\\)*" dir))) | 694 (if (and dir (not (string-match "\\([^*]*\\)/\\\*\\(/.*\\)*" dir))) |
695 (progn | 695 (progn |
696 | 696 |
697 ;; suffixes is nil => fname-stub is the file we are looking for | 697 ;; suffixes is nil => fname-stub is the file we are looking for |
698 ;; otherwise fname-stub is a stub, and we append a suffix | 698 ;; otherwise fname-stub is a stub, and we append a suffix |
699 (if suffixes | 699 (if suffixes |
700 (setq this-suffix (car suffixes)) | 700 (setq this-suffix (car suffixes)) |
701 (setq this-suffix "") | 701 (setq this-suffix "") |
702 (setq suffixes (list ""))) | 702 (setq suffixes (list ""))) |
703 | 703 |
704 (while (and suffixes (not found)) | 704 (while (and suffixes (not found)) |
705 | 705 |
706 (setq filename (concat fname-stub this-suffix)) | 706 (setq filename (concat fname-stub this-suffix)) |
707 (setq file (concat dir "/" filename)) | 707 (setq file (concat dir "/" filename)) |
708 | 708 |
709 (if (not ff-quiet-mode) | 709 (if (not ff-quiet-mode) |
710 (message "Finding %s..." file)) | 710 (message "Finding %s..." file)) |
711 | 711 |
712 (if (file-exists-p file) | 712 (if (file-exists-p file) |
713 (setq found file)) | 713 (setq found file)) |
714 | 714 |
715 (setq suffixes (cdr suffixes)) | 715 (setq suffixes (cdr suffixes)) |
716 (setq this-suffix (car suffixes)))) | 716 (setq this-suffix (car suffixes)))) |
717 | 717 |
718 ;; otherwise dir matches the '/*', so search each dir separately | 718 ;; otherwise dir matches the '/*', so search each dir separately |
719 (progn | 719 (progn |
933 (setq return-list (list (concat stub ".cc") | 933 (setq return-list (list (concat stub ".cc") |
934 (concat stub ".C"))) | 934 (concat stub ".C"))) |
935 )) | 935 )) |
936 (t | 936 (t |
937 nil)) | 937 nil)) |
938 | 938 |
939 return-list)) | 939 return-list)) |
940 | 940 |
941 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 941 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
942 ;; This section offers an example of user defined function to place point. | 942 ;; This section offers an example of user defined function to place point. |
943 ;; The regexps are Ada specific. | 943 ;; The regexps are Ada specific. |