[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.
https://reviews.llvm.org/D23006
Files:
clang-rename/tool/clang-rename.el
Index: clang-rename/tool/clang-rename.el
===================================================================
--- /dev/null
+++ clang-rename/tool/clang-rename.el
@@ -0,0 +1,46 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at <offset>.
+
+;; Keywords: tools, c
+
+;;; Commentary:
+
+;; 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.
+
+;;; Code:
+
+(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.
+ (interactive)
+ (revert-buffer t t)
+ )
+ )
+)
+
+(provide 'clang-rename)
+
+;;; clang-rename.el ends here
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23006.66289.patch
Type: text/x-patch
Size: 1631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160801/2e660da3/attachment.bin>
More information about the cfe-commits
mailing list