Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277433: [clang-rename] add basic Emacs integration (authored 
by omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D23006?vs=66437=66442#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23006

Files:
  clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
  clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
  clang-tools-extra/trunk/docs/clang-rename.rst

Index: clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-rename/tool/CMakeLists.txt
@@ -10,3 +10,10 @@
   )
 
 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)
Index: clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
===
--- clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
+++ clang-tools-extra/trunk/clang-rename/tool/clang-rename.el
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; 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
Index: clang-tools-extra/trunk/docs/clang-rename.rst
===
--- clang-tools-extra/trunk/docs/clang-rename.rst
+++ clang-tools-extra/trunk/docs/clang-rename.rst
@@ -20,15 +20,15 @@
 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
 `_-based tool, and it's easier to
 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
 `_). 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 @@
 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 @@
 -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 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and type new desired name. The [` 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
+`_.
+
+Once installed, you can point your cursor to symbols you want to rename, 

Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz marked 2 inline comments as done.
omtcyfz added a comment.

Thanks! Fixed.

Waiting few more hours just in case anyone will jump in and write few comments.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

lgtm with two nits.



Comment at: clang-rename/tool/CMakeLists.txt:14
@@ +13,3 @@
+
+install(PROGRAMS clang-rename.el
+  DESTINATION share/clang

Also include the vim integration clang-rename.py?


Comment at: docs/clang-rename.rst:99
@@ -98,3 +98,3 @@
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` 
key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The [` key`]
+(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)

s/print/type


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

In https://reviews.llvm.org/D23006#502814, @Eugene.Zelenko wrote:

> Please add install rule for clang-rename.el. See clang-format CMakeLists.txt 
> as example.


Good point! Thank you!

Done.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-02 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 66434.

https://reviews.llvm.org/D23006

Files:
  clang-rename/tool/CMakeLists.txt
  clang-rename/tool/clang-rename.el
  docs/clang-rename.rst

Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -20,15 +20,15 @@
 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
 `_-based tool, and it's easier to
 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
 `_). 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 @@
 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 @@
 -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 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The [` 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
+`_.
+
+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**.
Index: clang-rename/tool/clang-rename.el
===
--- /dev/null
+++ clang-rename/tool/clang-rename.el
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; 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
Index: clang-rename/tool/CMakeLists.txt
===
--- clang-rename/tool/CMakeLists.txt
+++ clang-rename/tool/CMakeLists.txt
@@ -10,3 +10,7 @@
   )
 
 install(TARGETS clang-rename RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-rename.el
+  DESTINATION share/clang
+  COMPONENT clang-rename)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Please add install rule for clang-rename.el. See clang-rename CMakeLists.txt as 
example.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz marked an inline comment as done.
omtcyfz added a comment.

https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz marked 2 inline comments as done.


Comment at: clang-rename/tool/clang-rename.el:28
@@ +27,3 @@
+(orig-buf (current-buffer))
+(file-name (buffer-file-name)))
+

alexfh wrote:
> For posterity, please add a short summary of the offline discussion.
`call-process-region` is used while contents of current buffer are to be 
replaced, but in case of `clang-rename` changes might affect all buffers, which 
doesn't make sense to take care of one buffer only.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 66341.

https://reviews.llvm.org/D23006

Files:
  clang-rename/tool/clang-rename.el
  docs/clang-rename.rst

Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -20,15 +20,15 @@
 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
 `_-based tool, and it's easier to
 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
 `_). 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 @@
 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 @@
 -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 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The [` 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
+`_.
+
+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**.
Index: clang-rename/tool/clang-rename.el
===
--- /dev/null
+++ clang-rename/tool/clang-rename.el
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; 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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-rename/tool/clang-rename.el:28
@@ +27,3 @@
+(orig-buf (current-buffer))
+(file-name (buffer-file-name)))
+

For posterity, please add a short summary of the offline discussion.


Comment at: docs/clang-rename.rst:104
@@ +103,3 @@
+
+clang-rename Emacs integration
+==

Either `Clang-rename Emacs integration` or just `Emacs integration`.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

All the comments seem to be addressed.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 66328.
omtcyfz marked 8 inline comments as done.

https://reviews.llvm.org/D23006

Files:
  clang-rename/tool/clang-rename.el
  docs/clang-rename.rst

Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -28,7 +28,7 @@
 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
 `_). 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 @@
 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.
@@ -96,7 +96,21 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` 
key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The [` 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.
+
+clang-rename 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
+`_.
+
+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**.
Index: clang-rename/tool/clang-rename.el
===
--- /dev/null
+++ clang-rename/tool/clang-rename.el
@@ -0,0 +1,45 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; 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


Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -28,7 +28,7 @@
 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
 `_). 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 @@
 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.
@@ -96,7 +96,21 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The [` key`]
+(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
 is a reference to a specific key 

Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: clang-rename/tool/clang-rename.el:20
@@ +19,3 @@
+  "Rename all instances of the symbol at the point using clang-rename"
+  (interactive "sEnter a new name: ")
+  (let (;; Emacs offset is 1-based.

hokein wrote:
> `s` is an extra character here?
No, it tells Emacs to read a string.


Comment at: clang-rename/tool/clang-rename.el:27
@@ +26,3 @@
+(let ((rename-command
+  (format "bash -f -c '%s -offset=%s -new-name=%s -i %s'"
+   clang-rename-binary offset new-name file-name)))

hokein wrote:
> Any reason why not use `call-process-region`?
/* discussed */


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-rename/tool/clang-rename.el:18
@@ +17,3 @@
+
+(defun clang-rename-upstream (new-name)
+  "Rename all instances of the symbol at the point using clang-rename"

The name should be just "clang-rename".


Comment at: docs/clang-rename.rst:100
@@ +99,3 @@
+`cr` and print new desired name. The
+[` key`]
+(http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)

Remove the linebreak after "The".


Comment at: docs/clang-rename.rst:114
@@ +113,3 @@
+Once installed, you can point your cursor to symbols you want to rename, press
+`M-X`, print `clang-rename` and new desired name.
+

hokein wrote:
> `print` doesn't make sense here? I think user should type `clang-rename` and 
> new name.
Yep, just s/print/type/.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-rename/tool/clang-rename.el:16
@@ +15,3 @@
+
+(defvar clang-rename-binary "clang-rename")
+

I think we should make `clang-rename` binary path configurable by making it a 
custom variable (using `defcustom`).


Comment at: clang-rename/tool/clang-rename.el:20
@@ +19,3 @@
+  "Rename all instances of the symbol at the point using clang-rename"
+  (interactive "sEnter a new name: ")
+  (let (;; Emacs offset is 1-based.

`s` is an extra character here?


Comment at: clang-rename/tool/clang-rename.el:27
@@ +26,3 @@
+(let ((rename-command
+  (format "bash -f -c '%s -offset=%s -new-name=%s -i %s'"
+   clang-rename-binary offset new-name file-name)))

Any reason why not use `call-process-region`?


Comment at: docs/clang-rename.rst:106
@@ +105,3 @@
+clang-rename Emacs integration
+
+

missing two "=".


Comment at: docs/clang-rename.rst:114
@@ +113,3 @@
+Once installed, you can point your cursor to symbols you want to rename, press
+`M-X`, print `clang-rename` and new desired name.
+

`print` doesn't make sense here? I think user should type `clang-rename` and 
new name.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Manuel, any other comments? Jens seems to be missing and I don't know about 
anyone else who is familiar with Emacs :(


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 66296.
omtcyfz marked 2 inline comments as done.

https://reviews.llvm.org/D23006

Files:
  clang-rename/tool/clang-rename.el
  docs/clang-rename.rst

Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -28,7 +28,7 @@
 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
 `_). 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 @@
 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.
@@ -96,7 +96,22 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` 
key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The
+[` 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.
+
+clang-rename 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
+`_.
+
+Once installed, you can point your cursor to symbols you want to rename, press
+`M-X`, print `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**.
Index: clang-rename/tool/clang-rename.el
===
--- /dev/null
+++ clang-rename/tool/clang-rename.el
@@ -0,0 +1,41 @@
+;;; clang-rename.el --- Renames every occurrence of a symbol found at .
+
+;; 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:
+
+(defvar clang-rename-binary "clang-rename")
+
+(defun clang-rename-upstream (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-upstream)
+
+;;; clang-rename.el ends here


Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -28,7 +28,7 @@
 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
 `_). 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 @@
 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.
@@ -96,7 +96,22 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The
+[` 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.
+
+clang-rename Emacs 

Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: clang-rename/tool/clang-rename.el:7
@@ +6,3 @@
+
+;; 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

klimek wrote:
> s/clang-format/clang-rename/, and fix docs in general :)
Aw, yeah. This block was just copied :D


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: clang-rename/tool/clang-rename.el:7
@@ +6,3 @@
+
+;; 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

s/clang-format/clang-rename/, and fix docs in general :)


Comment at: clang-rename/tool/clang-rename.el:17
@@ +16,3 @@
+;;
+;; to your .emacs configureation.
+

Typo.


https://reviews.llvm.org/D23006



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23006: [clang-rename] add basic Emacs integration

2016-08-01 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 66292.
omtcyfz added a comment.

Update docs by adding information about Emacs integration.


https://reviews.llvm.org/D23006

Files:
  clang-rename/tool/clang-rename.el
  docs/clang-rename.rst

Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -28,7 +28,7 @@
 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
 `_). 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 @@
 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.
@@ -96,7 +96,22 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[`` 
key``](http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_3)#Map_leader)
+`cr` and print new desired name. The
+[` 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.
+
+clang-rename 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
+`_.
+
+Once installed, you can point your cursor to symbols you want to rename, press
+`M-X`, print `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**.
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-upstream (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-upstream)
+
+;;; clang-rename.el ends here


Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -28,7 +28,7 @@
 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
 `_). 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 @@
 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.
@@ -96,7 +96,22 @@
 happen before running the tool**.
 
 Once installed, you can point your cursor to symbols you want to rename, press
-``cr`` and print new desired name. The
-[``