[PATCH] D23006: [clang-rename] add basic Emacs integration
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 1 02:35:40 PDT 2016
omtcyfz created this revision.
omtcyfz added reviewers: bkramer, alexfh, klimek.
omtcyfz added a subscriber: cfe-commits.
This patch aims to add very basic Emacs integration. My experience with Emacs is limited to few days, so I'm not sure whether I've done things correctly.
@@ -0,0 +1,46 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at <offset>.
+;; Keywords: tools, c
+;; This package allows to filter code through clang-format to fix its formatting.
+;; clang-format is a tool that formats C/C++/Obj-C code according to a set of
+;; style options, see <http://clang.llvm.org/docs/ClangFormatStyleOptions.html>.
+;; Note that clang-format 3.4 or newer is required.
+;; To install clang-rename.el make sure the directory of this file is in your
+;; 'load-path' and add
+;; (require 'clang-rename)
+;; to your .emacs configureation.
+(defvar clang-rename-binary "clang-rename")
+(defun clang-rename (new-name)
+ "Rename all instances of the symbol at the point using clang-rename"
+ (interactive "sEnter a new name: ")
+ (let (;; Emacs offset is 1-based.
+ (offset (- (point) 1))
+ (orig-buf (current-buffer))
+ (file-name (buffer-file-name)))
+ (let ((rename-command
+ (format "bash -f -c '%s -offset=%s -new-name=%s -i %s'"
+ clang-rename-binary offset new-name file-name)))
+ (message (format "Running clang-rename command %s" rename-command))
+ ;; Run clang-rename via bash.
+ (shell-command rename-command)
+ ;; Reload buffer.
+ (revert-buffer t t)
+;;; clang-rename.el ends here
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1631 bytes
Desc: not available
More information about the cfe-commits