clang-format-region assumes transient-mark-mode
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
llvm-toolchain-3.7 (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
From clang-format-3.5 to clang-format-3.6, the definition of clang-format-region changed in clang-format.el.
The old definition was this:
(defun clang-format-region ()
"Use clang-format to format the currently active region."
(interactive)
(let ((beg (if mark-active
(min (line-beginning
(end (if mark-active
(clang-format beg end)))
The new definition begins thus:
(defun clang-format-region (char-start char-end &optional style)
"Use clang-format to format the code between START and END according to STYLE.
If called interactively uses the region or the current statement if there
is no active region. If no style is given uses `clang-
(interactive
(if (use-region-p)
(list (region-beginning) (region-end))
(list (point) (point))))
...
(It continues quite a bit longer.)
The call to use-region-p always returns false if transient-mark-mode is turned off, e.g. via (transient-
This is a fix, barring some further subtlety I've missed:
(interactive
(if mark-active
(list (region-beginning) (region-end))
(list (point) (point))))
ProblemType: Bug
DistroRelease: Ubuntu 15.10
Package: clang-format-3.7 1:3.7-2ubuntu1
ProcVersionSign
Uname: Linux 4.2.0-16-generic x86_64
ApportVersion: 2.19.1-0ubuntu3
Architecture: amd64
CurrentDesktop: i3
Date: Sat Oct 31 17:34:38 2015
EcryptfsInUse: Yes
InstallationDate: Installed on 2015-10-23 (8 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Release amd64 (20150422)
SourcePackage: llvm-toolchain-3.7
UpgradeStatus: Upgraded to wily on 2015-10-23 (8 days ago)
I just found llvm.org/bugzilla, so I also filed the bug there:
https:/ /llvm.org/ bugs/show_ bug.cgi? id=25365