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
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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits