Function: locate-get-dirname
locate-get-dirname is a byte-compiled function defined in
locate.el.gz.
Signature
(locate-get-dirname)
Documentation
Return the directory name of the file mentioned on this line.
Source Code
;; Defined in /usr/src/emacs/lisp/locate.el.gz
;; You should only call this function on lines that contain a file name
;; listed by the locate program. Inside inserted subdirectories, or if
;; there is no file name on the current line, the return value is
;; meaningless. You can check whether the current line contains a file
;; listed by the locate program, using the function
;; `locate-main-listing-line-p'.
(defun locate-get-dirname ()
"Return the directory name of the file mentioned on this line."
(let (file (filepos (locate-get-file-positions)))
(if (setq file (buffer-substring (nth 0 filepos) (nth 1 filepos)))
(progn
;; Get rid of the mouse-face property that file names have.
(set-text-properties 0 (length file) nil file)
(setq file (file-name-directory file))
;; Unquote names quoted by ls or by dired-insert-directory.
;; Using read to unquote is much faster than substituting
;; \007 (4 chars) -> ^G (1 char) etc. in a lisp loop.
(setq file
(read
(concat "\""
;; some ls -b don't escape quotes, argh!
;; This is not needed for GNU ls, though.
(or (dired-string-replace-match
"\\([^\\]\\|\\`\\)\"" file "\\1\\\\\"" nil t)
file)
"\"")))))
(and file buffer-file-coding-system
(not file-name-coding-system)
(setq file (encode-coding-string file buffer-file-coding-system)))
file))