summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorKirill Bobyrev <omtcyfz@gmail.com>2016-08-02 08:51:26 +0000
committerKirill Bobyrev <omtcyfz@gmail.com>2016-08-02 08:51:26 +0000
commitaa4845004df31da0f4b50d12bb2b86a3a65652d7 (patch)
tree00c0fba3241964496ed15630692114f1ef945f31 /clang-tools-extra
parent7b360f24416ef800a7745ecc8e110f12f0ebc06a (diff)
downloadbcm5719-llvm-aa4845004df31da0f4b50d12bb2b86a3a65652d7.tar.gz
bcm5719-llvm-aa4845004df31da0f4b50d12bb2b86a3a65652d7.zip
[clang-rename] add basic Emacs integration
This patch aims to add very basic Emacs integration. Reviewers: hokein, alexfh Differential Revision: https://reviews.llvm.org/D23006 llvm-svn: 277433
Diffstat (limited to 'clang-tools-extra')
-rw-r--r--clang-tools-extra/clang-rename/tool/CMakeLists.txt7
-rw-r--r--clang-tools-extra/clang-rename/tool/clang-rename.el45
-rw-r--r--clang-tools-extra/docs/clang-rename.rst28
3 files changed, 73 insertions, 7 deletions
diff --git a/clang-tools-extra/clang-rename/tool/CMakeLists.txt b/clang-tools-extra/clang-rename/tool/CMakeLists.txt
index d19073fc1bb..d2109cdcab7 100644
--- a/clang-tools-extra/clang-rename/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-rename/tool/CMakeLists.txt
@@ -10,3 +10,10 @@ target_link_libraries(clang-rename
)
install(TARGETS clang-rename RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-rename.py
+ DESTINATION share/clang
+ COMPONENT clang-rename)
+install(PROGRAMS clang-rename.el
+ DESTINATION share/clang
+ COMPONENT clang-rename)
diff --git a/clang-tools-extra/clang-rename/tool/clang-rename.el b/clang-tools-extra/clang-rename/tool/clang-rename.el
new file mode 100644
index 00000000000..0d715d2efea
--- /dev/null
+++ b/clang-tools-extra/clang-rename/tool/clang-rename.el
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at <offset>.
+
+;; Keywords: tools, c
+
+;;; Commentary:
+
+;; 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 configuration.
+
+;;; Code:
+
+(defcustom clang-rename-binary "clang-rename"
+ "Path to clang-rename executable."
+ :type 'hook
+ :options '(turn-on-auto-fill flyspell-mode)
+ :group 'wp)
+
+(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
diff --git a/clang-tools-extra/docs/clang-rename.rst b/clang-tools-extra/docs/clang-rename.rst
index a6d82180631..475c9506e1f 100644
--- a/clang-tools-extra/docs/clang-rename.rst
+++ b/clang-tools-extra/docs/clang-rename.rst
@@ -20,7 +20,7 @@ to `the LLVM bugtracker <https://llvm.org/bugs>`_ will definitely help the
project. If you have any ideas or suggestions, you might want to put a feature
request there.
-Using clang-rename
+Using Clang-Rename
==================
:program:`clang-rename` is a `LibTooling
@@ -28,7 +28,7 @@ Using clang-rename
work with if you set up a compile command database for your project (for an
example of how to do this see `How To Setup Tooling For LLVM
<http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html>`_). You can also
-specify compilation options on the command line after ``--``:
+specify compilation options on the command line after `--`:
.. code-block:: console
@@ -47,7 +47,7 @@ only. It is planned to extend the tool's functionality to support multi-TU
renaming actions in the future.
:program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim, and improve the workflow of users.
+editors, such as Vim and Emacs, and improve the workflow of users.
Although a command line interface exists, it is highly recommended to use the
text editor interface instead for better experience.
@@ -84,8 +84,8 @@ text editor interface instead for better experience.
-version - Display the version of this program
-clang-rename Vim integration
-============================
+Vim Integration
+===============
You can call :program:`clang-rename` directly from Vim! To set up
:program:`clang-rename` integration for Vim see
@@ -96,7 +96,21 @@ Please note that **you have to save all buffers, in which the replacement will
happen before running the tool**.
Once installed, you can point your cursor to symbols you want to rename, press
-``<leader>cr`` and print new desired name. The
-[``<leader> key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`<leader>cr` and type new desired name. The [`<leader> key`]
+(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
is a reference to a specific key defined by the mapleader variable and is bound
to backslash by default.
+
+Emacs Integration
+=================
+
+You can also use :program:`clang-rename` while using Emacs! To set up
+:program:`clang-rename` integration for Emacs see
+`clang-rename/tool/clang-rename.el
+<http://reviews.llvm.org/diffusion/L/browse/clang-tools-extra/trunk/clang-rename/tool/clang-rename.el>`_.
+
+Once installed, you can point your cursor to symbols you want to rename, press
+`M-X`, type `clang-rename` and new desired name.
+
+Please note that **you have to save all buffers, in which the replacement will
+happen before running the tool**.
OpenPOWER on IntegriCloud