mirror of
https://github.com/golang/go
synced 2024-11-05 11:46:12 -07:00
refactor/rename: allow passing -force flag from Emacs
Change-Id: Iac9355bc8a98cf61cb3d4ff871723ce466d38531 Reviewed-on: https://go-review.googlesource.com/2912 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
b09f9e69fa
commit
4a084c7791
@ -25,10 +25,12 @@
|
|||||||
:type 'string
|
:type 'string
|
||||||
:group 'go-rename)
|
:group 'go-rename)
|
||||||
|
|
||||||
(defun go-rename (new-name)
|
(defun go-rename (new-name &optional force)
|
||||||
"Rename the entity denoted by the identifier at point, using
|
"Rename the entity denoted by the identifier at point, using
|
||||||
the `gorename' tool."
|
the `gorename' tool. With FORCE, call `gorename' with the
|
||||||
(interactive (list (read-string "New name: " (thing-at-point 'symbol))))
|
`-force' flag."
|
||||||
|
(interactive (list (read-string "New name: " (thing-at-point 'symbol))
|
||||||
|
current-prefix-arg))
|
||||||
(if (not buffer-file-name)
|
(if (not buffer-file-name)
|
||||||
(error "Cannot use go-rename on a buffer without a file name"))
|
(error "Cannot use go-rename on a buffer without a file name"))
|
||||||
;; It's not sufficient to save the current buffer if modified,
|
;; It's not sufficient to save the current buffer if modified,
|
||||||
@ -50,7 +52,7 @@ the `gorename' tool."
|
|||||||
(with-current-buffer (get-buffer-create "*go-rename*")
|
(with-current-buffer (get-buffer-create "*go-rename*")
|
||||||
(setq buffer-read-only nil)
|
(setq buffer-read-only nil)
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(let ((args (list go-rename-command nil t nil posflag "-to" new-name)))
|
(let ((args (append (list go-rename-command nil t nil posflag "-to" new-name) (if force '("-force")))))
|
||||||
;; Log the command to *Messages*, for debugging.
|
;; Log the command to *Messages*, for debugging.
|
||||||
(message "Command: %s:" args)
|
(message "Command: %s:" args)
|
||||||
(message "Running gorename...")
|
(message "Running gorename...")
|
||||||
|
Loading…
Reference in New Issue
Block a user