Commit 96c1776c authored by Peter Breton's avatar Peter Breton
Browse files

Add locate-word-at-point function

In locate function, default to using locate-word-at-point as input
Run dired-mode-hook in locate function
parent 58f2fab8
...@@ -170,6 +170,17 @@ Otherwise, that behavior is invoked via a prefix argument." ...@@ -170,6 +170,17 @@ Otherwise, that behavior is invoked via a prefix argument."
(defun locate-default-make-command-line (search-string) (defun locate-default-make-command-line (search-string)
(list locate-command search-string)) (list locate-command search-string))
(defun locate-word-at-point ()
(let ((pt (point)))
(buffer-substring-no-properties
(save-excursion
(skip-chars-backward "-a-zA-Z0-9.")
(point))
(save-excursion
(skip-chars-forward "-a-zA-Z0-9.")
(skip-chars-backward "." pt)
(point)))))
;;;###autoload ;;;###autoload
(defun locate (arg search-string &optional filter) (defun locate (arg search-string &optional filter)
"Run the program `locate', putting results in `*Locate*' buffer. "Run the program `locate', putting results in `*Locate*' buffer.
...@@ -181,7 +192,7 @@ With prefix arg, prompt for the locate command to run." ...@@ -181,7 +192,7 @@ With prefix arg, prompt for the locate command to run."
(and (not current-prefix-arg) locate-prompt-for-command)) (and (not current-prefix-arg) locate-prompt-for-command))
(read-from-minibuffer "Run locate command: " (read-from-minibuffer "Run locate command: "
nil nil nil 'locate-history-list) nil nil nil 'locate-history-list)
(read-from-minibuffer "Locate: " nil nil (read-from-minibuffer "Locate: " (locate-word-at-point) nil
nil 'locate-history-list) nil 'locate-history-list)
))) )))
(let* ((locate-cmd-list (funcall locate-make-command-line search-string)) (let* ((locate-cmd-list (funcall locate-make-command-line search-string))
...@@ -212,6 +223,7 @@ With prefix arg, prompt for the locate command to run." ...@@ -212,6 +223,7 @@ With prefix arg, prompt for the locate command to run."
(and (not (string-equal (buffer-name) locate-buffer-name)) (and (not (string-equal (buffer-name) locate-buffer-name))
(switch-to-buffer-other-window locate-buffer-name)) (switch-to-buffer-other-window locate-buffer-name))
(run-hooks 'dired-mode-hook)
(run-hooks 'locate-post-command-hook) (run-hooks 'locate-post-command-hook)
) )
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment