Remove compatibility code for Emacs 22 and earlier

* yasnippet.el (region-active-p, locate-dominating-stop-dir-regexp)
(locate-dominating-file): Remove.
This commit is contained in:
Noam Postavsky 2018-05-21 22:02:57 -04:00
parent e67592ce1b
commit 79b90c9489

View File

@ -4928,62 +4928,6 @@ object satisfying `yas--field-p' to restrict the expansion to.")))
(apply #'format (concat "[yas] " format-control) format-args))
;;; Some hacks:
;;
;; The functions
;;
;; `locate-dominating-file'
;; `region-active-p'
;;
;; added for compatibility in emacsen < 23
(unless (>= emacs-major-version 23)
(unless (fboundp 'region-active-p)
(defun region-active-p () (and transient-mark-mode mark-active)))
(unless (fboundp 'locate-dominating-file)
(defvar locate-dominating-stop-dir-regexp
"\\`\\(?:[\\/][\\/][^\\/]+[\\/]\\|/\\(?:net\\|afs\\|\\.\\.\\.\\)/\\)\\'"
"Regexp of directory names which stop the search in `locate-dominating-file'.
Any directory whose name matches this regexp will be treated like
a kind of root directory by `locate-dominating-file' which will stop its search
when it bumps into it.
The default regexp prevents fruitless and time-consuming attempts to find
special files in directories in which filenames are interpreted as hostnames,
or mount points potentially requiring authentication as a different user.")
(defun locate-dominating-file (file name)
"Look up the directory hierarchy from FILE for a file named NAME.
Stop at the first parent directory containing a file NAME,
and return the directory. Return nil if not found."
;; We used to use the above locate-dominating-files code, but the
;; directory-files call is very costly, so we're much better off doing
;; multiple calls using the code in here.
;;
;; Represent /home/luser/foo as ~/foo so that we don't try to look for
;; `name' in /home or in /.
(setq file (abbreviate-file-name file))
(let ((root nil)
try)
(while (not (or root
(null file)
;; FIXME: Disabled this heuristic because it is sometimes
;; inappropriate.
;; As a heuristic, we stop looking up the hierarchy of
;; directories as soon as we find a directory belonging
;; to another user. This should save us from looking in
;; things like /net and /afs. This assumes that all the
;; files inside a project belong to the same user.
;; (let ((prev-user user))
;; (setq user (nth 2 (file-attributes file)))
;; (and prev-user (not (equal user prev-user))))
(string-match locate-dominating-stop-dir-regexp file)))
(setq try (file-exists-p (expand-file-name name file)))
(cond (try (setq root file))
((equal file (setq file (file-name-directory
(directory-file-name file))))
(setq file nil))))
root))))
;;; Unloading
(defvar unload-function-defs-list) ; loadhist.el