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 . + +;; 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 . +;; 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