;; Copyright (C) 2013 Free Software Foundation, Inc.
;; Author: Leo Liu <sdl.web@gmail.com>
-;; Version: 0.6.5
+;; Version: 0.6.6
;; Keywords: tools, convenience
;; Created: 2013-01-29
;; URL: https://github.com/leoliu/ggtags
(if (ggtags-cache-stale-p root)
(let* ((default-directory (file-name-as-directory root))
(tags (with-demoted-errors
- (split-string
- (with-output-to-string
- (call-process "global" nil (list standard-output nil)
- nil "-c" (or prefix "")))))))
+ (process-lines "global" "-c" (or prefix "")))))
(and tags (ggtags-cache-set root tags))
tags)
(cadr (ggtags-cache-get root)))))
(setq-local compilation-auto-jump-to-first-error nil)
(remove-hook 'compilation-finish-functions 'ggtags-handle-single-match t))))
+(defun ggtags-query-replace (from to &optional delimited directory)
+ "Query replace FROM with TO on all files in DIRECTORY."
+ (interactive
+ (append (query-replace-read-args "Query replace (regexp)" t t)
+ (list (read-directory-name "In directory: " nil nil t))))
+ (let ((default-directory (file-name-as-directory directory)))
+ (ggtags-check-root-directory)
+ (dolist (file (process-lines "global" "-P" "-l" "."))
+ (let ((file (expand-file-name file directory)))
+ (when (file-exists-p file)
+ (let* ((message-log-max nil)
+ (visited (get-file-buffer file))
+ (buffer (or visited
+ (with-demoted-errors
+ (find-file-noselect file)))))
+ (when buffer
+ (set-buffer buffer)
+ (if (save-excursion
+ (goto-char (point))
+ (re-search-forward from nil t))
+ (progn
+ (switch-to-buffer (current-buffer))
+ (perform-replace from to t t delimited
+ nil multi-query-replace-map))
+ (message "Nothing to do for `%s'" file)
+ (or visited (kill-buffer))))))))))
+
(defun ggtags-delete-tag-files ()
"Delete the tag files generated by gtags."
(interactive)