* bug#18970: 24.3; indent region fails in C++ mode after adding a #include
@ 2014-11-06 3:44 Piotr Sipika
[not found] ` <mailman.12996.1415245577.1147.bug-gnu-emacs@gnu.org>
0 siblings, 1 reply; 8+ messages in thread
From: Piotr Sipika @ 2014-11-06 3:44 UTC (permalink / raw)
To: 18970
--text follows this line--
1. Edited a C++ header file in a buffer.
2. Switched to another buffer.
3. Went back to buffer in #1, above.
4. Added a #include to the top of the buffer.
5. Indentation for all code blocks following the include, when using
TAB, resets to line 0.
In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7)
of 2014-03-07 on lamiak, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11501000
System Description: Ubuntu 14.04.1 LTS
Configured using:
`configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
'--localstatedir=/var/lib' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
'--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
'--with-x-toolkit=gtk3' '--with-toolkit-scroll-bars'
'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'
'CPPFLAGS=-D_FORTIFY_SOURCE=2''
Important settings:
value of $LC_MONETARY: en_US.UTF-8
value of $LC_NUMERIC: en_US.UTF-8
value of $LC_TIME: en_US.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: C++/l
Minor modes in effect:
shell-dirtrack-mode: t
show-paren-mode: t
display-time-mode: t
tooltip-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
abbrev-mode: t
Recent input:
b <return> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <return> C-y <return> C-x
C-s <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <up> <up> C-k C-k
C-k C-x C-s <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <delete> C-x C-s <end> <return> <tab>
<tab> <tab> <tab> <tab> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <tab> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <tab> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <tab> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <tab> <up> <up> <up> <up> <up> <up> <up> <up>
<tab> <down> <down> <tab> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<down> <tab> <down> <down> <down> <down> <down> <tab>
<up> <up> <up> <up> <up> <up> <up> <up> <down> <down>
<down> <escape> x s u <tab> <tab> b <tab> <tab> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> b u <tab> <backspace> <backspace> r e <tab>
p o <tab> r t <tab> <return>
Load-path shadows:
/usr/share/emacs/24.3/site-lisp/debian-startup hides
/usr/share/emacs/site-lisp/debian-startup
Features:
(shadow sort gnus-util mail-extr emacsbug message cl-macs gv format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils help-mode pcmpl-unix shell pcomplete
comint ansi-color ring make-mode misearch multi-isearch cc-langs cl
cl-lib cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs cus-edit easymenu wid-edit edmacro kmacro
paren autoinsert cus-start cus-load time time-date tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#18970: 24.3; indent region fails in C++ mode after adding a #include
[not found] ` <mailman.12996.1415245577.1147.bug-gnu-emacs@gnu.org>
@ 2014-11-06 11:54 ` Alan Mackenzie
2014-11-06 13:53 ` Piotr Sipika
[not found] ` <545D3F5E.8030801@gmail.com>
0 siblings, 2 replies; 8+ messages in thread
From: Alan Mackenzie @ 2014-11-06 11:54 UTC (permalink / raw)
To: Piotr Sipika; +Cc: 18970
Hello, Piotr.
In article <mailman.12996.1415245577.1147.bug-gnu-emacs@gnu.org> you wrote:
> 1. Edited a C++ header file in a buffer.
> 2. Switched to another buffer.
> 3. Went back to buffer in #1, above.
> 4. Added a #include to the top of the buffer.
> 5. Indentation for all code blocks following the include, when using
> TAB, resets to line 0.
This bug will be dependent on the exact contents of the file, or at least
the first few hundred or thousand bytes in it. Is there any chance you
could post the file as it was just before you edited it in step 1., and
say exactly what keys you used for 1. - 4.?
Thanks!
> In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7)
> of 2014-03-07 on lamiak, modified by Debian
> Windowing system distributor `The X.Org Foundation', version 11.0.11501000
> System Description: Ubuntu 14.04.1 LTS
[ ... ]
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#18970: 24.3; indent region fails in C++ mode after adding a #include
2014-11-06 11:54 ` Alan Mackenzie
@ 2014-11-06 13:53 ` Piotr Sipika
2014-11-07 16:14 ` Piotr Sipika
[not found] ` <545D3F5E.8030801@gmail.com>
1 sibling, 1 reply; 8+ messages in thread
From: Piotr Sipika @ 2014-11-06 13:53 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 18970
[-- Attachment #1: Type: text/plain, Size: 1025 bytes --]
Hi Alan,
On 11/06/2014 06:54 AM, Alan Mackenzie wrote:
> This bug will be dependent on the exact contents of the file, or at least
> the first few hundred or thousand bytes in it. Is there any chance you
> could post the file as it was just before you edited it in step 1., and
> say exactly what keys you used for 1. - 4.?
Certainly.
The steps were:
1. Edited a C++ header file in a buffer.
The file is attached (resource.h)
2. Switched to another buffer.
C-x b [ENTER]
(possibly edited the other buffer, but don't recall the exact keys...)
3. Went back to buffer in #1, above.
C-x b [ENTER]
4. Added a #include to the top of the buffer.
Went to line 9, moved the two #include's there down using [ENTER] (twice).
Added: #include <pthread.h> [ENTER]
Saved buffer: C-x C-s
5. Indentation for all code blocks following the include, when using
TAB, resets to line 0.
Went down to the declaration of findLocation() and hit [TAB]; the
function ended up being moved to line 0.
> Thanks!
Hope this helps...
Cheers,
Piotr
[-- Attachment #2: resource.h --]
[-- Type: text/plain, Size: 1339 bytes --]
#ifndef LXWEATHER_RESOURCE_H_
#define LXWEATHER_RESOURCE_H_
#include "exception.h"
#include "location.h"
#include "transport.h"
#include <string>
#include <vector>
namespace LXWeather
{
typedef enum
{
RESOURCE_UNKNOWN,
RESOURCE_YAHOO,
RESOURCE_MAX
} ResourceType;
class ResourceException : public Exception
{
public:
ResourceException(const std::string &msg) : Exception(msg) {};
};
class Resource
{
public:
Resource(const ResourceType type, Transport &transport) :
type_(type),
location_(NULL),
transport_(transport) {};
virtual ~Resource()
{
if (location_)
{
delete location_;
}
};
ResourceType type() { return type_; };
Location *location() const { return location_; };
void location(Location *location)
{
if (location_)
{
delete location_;
}
location_ = location;
};
Transport &transport() const { return transport_; };
virtual std::vector<Location *> findLocation(const std::string &name) = 0;
/* virtual std::string forecast(const std::string &URI) = 0;*/
protected:
ResourceType type_;
Location *location_;
Transport &transport_;
};
} /* end namespace LXWeather */
#endif /* LXWEATHER_RESOURCE_H_ */
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#18970: 24.3; indent region fails in C++ mode after adding a #include
2014-11-06 13:53 ` Piotr Sipika
@ 2014-11-07 16:14 ` Piotr Sipika
0 siblings, 0 replies; 8+ messages in thread
From: Piotr Sipika @ 2014-11-07 16:14 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 18970
[-- Attachment #1: Type: text/plain, Size: 901 bytes --]
Alan, here's another instance of the problem:
> The steps were:
> 1. Edited a C++ header file in a buffer.
The file is attached (libxmlparser.h).
I've had it open in a buffer for a while and have edited it successfully
(without the indentation problem) within the current emacs session.
I just switched to it from another buffer.
> 4. Added a #include to the top of the buffer.
4.1 I added a newline on line 8.
4.2 I then added another #include (pasted using C-y): #include
<libxml/xpath.h>
4.3 I then added another newline under the new #include.
> 5. Indentation for all code blocks following the include, when using
Tested line 14 (of the updated file) with a [TAB] and noticed the
forward declaration got moved to column 0.
When I undo all changes (steps 4.3 to 4.1), indentation is OK (remains
at respective column). When I repeat the steps, indentation gets moved
to column 0.
Best!
Piotr
[-- Attachment #2: libxmlparser.h --]
[-- Type: text/plain, Size: 942 bytes --]
#ifndef LXWEATHER_LIBXMLPARSER_H_
#define LXWEATHER_LIBXMLPARSER_H_
#include "parser.h"
#include <pthread.h>
namespace LXWeather
{
/* forward declarations */
class Location;
class Forecast;
class LibXMLParser : public Parser
{
public:
LibXMLParser(pthread_mutex_t *mutex);
virtual ~LibXMLParser();
virtual std::vector<Location *> parseLocationList(const std::string &data);
virtual void parseForecast(const std::string &data, Forecast *forecast);
protected:
class XPATHWrapper
{
public:
XPATHWrapper() : pContext_(NULL)
{
xmlXPathInit();
}
~NanoHTTPWrapper()
{
xmlNanoHTTPClose(pContext_);
}
std::string get(const std::string &URI, int *retcode);
private:
void *pContext_;
};
private:
pthread_mutex_t *mutex_;
};
} /* end namespace LXWeather */
#endif /* LXWEATHER_LIBXMLPARSER_H_ */
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#18970: 24.3; indent region fails in C++ mode after adding a #include
[not found] ` <545D3F5E.8030801@gmail.com>
@ 2014-11-07 23:24 ` Alan Mackenzie
2014-11-08 2:27 ` Piotr Sipika
2014-11-08 3:08 ` Piotr Sipika
0 siblings, 2 replies; 8+ messages in thread
From: Alan Mackenzie @ 2014-11-07 23:24 UTC (permalink / raw)
To: Piotr Sipika; +Cc: 18970
Hello, Piotr.
On Fri, Nov 07, 2014 at 04:53:34PM -0500, Piotr Sipika wrote:
> Hi Alan,
> > This bug will be dependent on the exact contents of the file, or at least
> > the first few hundred or thousand bytes in it. Is there any chance you
> > could post the file as it was just before you edited it in step 1., and
> > say exactly what keys you used for 1. - 4.?
> Hope this will help you: it seems that this problem has a higher rate of
> occurrence when I kill the line with the #include (C-k) and then paste
> it in (C-y). The buffer where the #include is inserted is the one where
> the indentation problem occurs (it may be the same buffer in which the
> line was killed).
Yes, indeed, that helps a great deal!
There was a problem with C-y'ing #include lines into a buffer back in
May 2013, which was fixed, and the fix got into Emacs 24.4 (which was
released a few days ago).
To confirm that your problem is the same one, would you please do the
following:
(i) Kill a line starting with "#include" with C-k, then yank it back
again with C-y.
(ii) Move point to the beginning of that line and type C-u C-x =
(`what-cursor-position' with a C-u prefix argument).
(iii) You should see something like this:
########################################################################
position: 63 of 1339 (5%), column: 0
character: # (displayed as #) (codepoint 35, #o43, #x23)
preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x23
syntax: . which means: punctuation
category: .:Base, a:ASCII, l:Latin, r:Roman
to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET
NAME"
buffer code: #x23
file code: #x23 (encoded by coding system undecided-unix)
display: terminal code #x23
Character code properties: customize what to show
name: NUMBER SIGN
general-category: Po (Punctuation, Other)
decomposition: (35) ('#')
There are text properties here:
c-in-sws t
c-is-sws t
category c-cpp-delimiter
face font-lock-preprocessor-face
fontified t
risky-local-variable t
syntax-table nil <===================================================
[back]
########################################################################
If you see the syntax-table text property set to nil, as in the above,
then we have found the bug.
Either upgrade your Emacs to version 24.4, or apply the following patch
to ..../emacs-24.3/lisp/progmodes/cc-mode.el:
=== modified file 'lisp/progmodes/cc-mode.el'
--- lisp/progmodes/cc-mode.el 2013-05-02 11:18:18 +0000
+++ lisp/progmodes/cc-mode.el 2013-05-27 13:30:21 +0000
@@ -1077,12 +1077,13 @@
(setq beg end)))
;; C-y is capable of spuriously converting category properties
- ;; c-</>-as-paren-syntax into hard syntax-table properties. Remove
- ;; these when it happens.
+ ;; c-</>-as-paren-syntax and c-cpp-delimiter into hard syntax-table
+ ;; properties. Remove these when it happens.
(c-clear-char-property-with-value beg end 'syntax-table
c-<-as-paren-syntax)
(c-clear-char-property-with-value beg end 'syntax-table
c->-as-paren-syntax)
+ (c-clear-char-property-with-value beg end 'syntax-table nil)
(c-trim-found-types beg end old-len) ; maybe we don't need all of these.
(c-invalidate-sws-region-after beg end)
[If you have any problems applying the patch, get back to me privately.]
After applying the patch, byte compile cc-mode.el either with "M-x
byte-compile-file" inside emacs, or do it from the command line like
this:
$ emacs -Q -batch -f batch-byte-compile .../emacs-24.3/lisp/progmodes/cc-mode.el
Then copy the compiled file cc-mode.elc to where emacs normally loads it
from. You can find this with "M-x locate-library<CR>cc-mode<CR>" from
inside emacs.
Restart Emacs, and hopefully the bug will be gone. Please let me know
whether or not this works.
Thanks!
> Piotr
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#18970: 24.3; indent region fails in C++ mode after adding a #include
2014-11-07 23:24 ` Alan Mackenzie
@ 2014-11-08 2:27 ` Piotr Sipika
2014-11-08 3:08 ` Piotr Sipika
1 sibling, 0 replies; 8+ messages in thread
From: Piotr Sipika @ 2014-11-08 2:27 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 18970
> To confirm that your problem is the same one, would you please do the
> following:
> (i) Kill a line starting with "#include" with C-k, then yank it back
> again with C-y.
> (ii) Move point to the beginning of that line and type C-u C-x =
> (`what-cursor-position' with a C-u prefix argument).
> (iii) You should see something like this:
Awesome directions, here's the output from my instance of that command:
position: 110 of 3316 (3%), column: 0
character: # (displayed as #) (codepoint 35, #o43, #x23)
preferred charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x23
syntax: . which means: punctuation
category: .:Base, a:ASCII, l:Latin, r:Roman
to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET NAME"
buffer code: #x23
file code: #x23 (encoded by coding system undecided-unix)
display: by this font (glyph code)
xft:-unknown-Liberation
Mono-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1 (#x06)
Character code properties: customize what to show
name: NUMBER SIGN
general-category: Po (Punctuation, Other)
decomposition: (35) ('#')
There are text properties here:
c-in-sws t
c-is-sws t
category c-cpp-delimiter
face font-lock-preprocessor-face
fontified t
risky-local-variable t
syntax-table nil
> If you see the syntax-table text property set to nil, as in the above,
> then we have found the bug.
As you can see that is the exact output indicating the bug.
> Either upgrade your Emacs to version 24.4, or apply the following patch
> to ..../emacs-24.3/lisp/progmodes/cc-mode.el:
Thank you for the patch and further directions/suggestions.
> Restart Emacs, and hopefully the bug will be gone. Please let me know
> whether or not this works.
Will do.
Best!
Piotr
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#18970: 24.3; indent region fails in C++ mode after adding a #include
2014-11-07 23:24 ` Alan Mackenzie
2014-11-08 2:27 ` Piotr Sipika
@ 2014-11-08 3:08 ` Piotr Sipika
2014-11-08 8:29 ` Alan Mackenzie
1 sibling, 1 reply; 8+ messages in thread
From: Piotr Sipika @ 2014-11-08 3:08 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 18970
On 11/07/2014 06:24 PM, Alan Mackenzie wrote:
> Either upgrade your Emacs to version 24.4, or apply the following patch
> to ..../emacs-24.3/lisp/progmodes/cc-mode.el:
I chose the former (upgrade to Emacs 24.4; built from source with exact
options as shown in original bug report) and the erroneous behavior is
no longer there.
Thank you, again, for your help.
Please feel free to close this bug as resolved.
Cheers!
Piotr
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#18970: 24.3; indent region fails in C++ mode after adding a #include
2014-11-08 3:08 ` Piotr Sipika
@ 2014-11-08 8:29 ` Alan Mackenzie
0 siblings, 0 replies; 8+ messages in thread
From: Alan Mackenzie @ 2014-11-08 8:29 UTC (permalink / raw)
To: 18970-done
The bug was fixed on 2013-05-27 in revision #112742, and released in
Emacs 24.4.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-11-08 8:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 3:44 bug#18970: 24.3; indent region fails in C++ mode after adding a #include Piotr Sipika
[not found] ` <mailman.12996.1415245577.1147.bug-gnu-emacs@gnu.org>
2014-11-06 11:54 ` Alan Mackenzie
2014-11-06 13:53 ` Piotr Sipika
2014-11-07 16:14 ` Piotr Sipika
[not found] ` <545D3F5E.8030801@gmail.com>
2014-11-07 23:24 ` Alan Mackenzie
2014-11-08 2:27 ` Piotr Sipika
2014-11-08 3:08 ` Piotr Sipika
2014-11-08 8:29 ` Alan Mackenzie
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).