all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#6158: bug in hideshow (trunk)
@ 2010-05-10 15:32 Theodor Rascanu
  2010-05-26 22:53 ` bug#6158: Theodor Rascanu
  0 siblings, 1 reply; 2+ messages in thread
From: Theodor Rascanu @ 2010-05-10 15:32 UTC (permalink / raw)
  To: 6158


[-- Attachment #1.1: Type: text/plain, Size: 768 bytes --]

Hi all,

I guess I have found a the bug in the hideshow package:

Assume the following c++ code:

inline int round_to_next_power2(register unsigned int x){
  //if(x!=32){
  x--;
  x |= (x >> 1);
  x |= (x >> 2);
  x |= (x >> 4);
  x |= (x >> 8);
  x |= (x >> 16);
  return x + 1;
  //}
}

Ok this example do not make much sense programming wise but it shows the
probelm:
Hiding this function will not work.
Having the cursor somewhere inside the function outside the commented lines
and trying to hide it (i.e. by C-c @ C-c) will produce the following:

inline int round_to_next_power2(register unsigned int x){
//if(x!=32){... }

Attached is a patch producing the expected behaviour:
inline int round_to_next_power2(register unsigned int x){... }

Greetings,
Theodor

[-- Attachment #1.2: Type: text/html, Size: 953 bytes --]

[-- Attachment #2: emacs-hideshow_comment.patch --]
[-- Type: text/x-patch, Size: 829 bytes --]

--- lisp/progmodes/hideshow.el.orig	2010-05-10 13:21:48.555732323 +0200
+++ lisp/progmodes/hideshow.el	2010-05-10 13:21:40.745646130 +0200
@@ -690,10 +690,12 @@ Return point, or nil if original point w
         (point)
       ;; look backward for the start of a block that contains the cursor
       (while (and (re-search-backward hs-block-start-regexp nil t)
-                  (not (setq done
-                             (< here (save-excursion
-                                       (hs-forward-sexp (match-data t) 1)
-                                       (point)))))))
+                  (setq done
+			     (< here (save-excursion
+				       (hs-forward-sexp (match-data t) 1)
+				       (point))))
+		  (hs-inside-comment-p)
+		  (not (setq done nil))))
       (if done
           (point)
         (goto-char here)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#6158:
  2010-05-10 15:32 bug#6158: bug in hideshow (trunk) Theodor Rascanu
@ 2010-05-26 22:53 ` Theodor Rascanu
  0 siblings, 0 replies; 2+ messages in thread
From: Theodor Rascanu @ 2010-05-26 22:53 UTC (permalink / raw)
  To: 6158


[-- Attachment #1.1: Type: text/plain, Size: 57 bytes --]

Hi again,

here a enhanced version of the patch.

greets

[-- Attachment #1.2: Type: text/html, Size: 73 bytes --]

[-- Attachment #2: emacs-hideshow_comment.patch --]
[-- Type: text/x-patch, Size: 783 bytes --]

--- lisp/progmodes/hideshow.el.orig	2010-05-12 18:28:06.543936429 +0200
+++ lisp/progmodes/hideshow.el	2010-05-12 18:27:40.212936751 +0200
@@ -691,9 +691,11 @@ Return point, or nil if original point w
       ;; look backward for the start of a block that contains the cursor
       (while (and (re-search-backward hs-block-start-regexp nil t)
                   (not (setq done
-                             (< here (save-excursion
-                                       (hs-forward-sexp (match-data t) 1)
-                                       (point)))))))
+			     (and (< here 
+				     (save-excursion
+				       (hs-forward-sexp (match-data t) 1)
+				       (point)))
+				  (eq (hs-inside-comment-p) nil))))))
       (if done
           (point)
         (goto-char here)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-26 22:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-10 15:32 bug#6158: bug in hideshow (trunk) Theodor Rascanu
2010-05-26 22:53 ` bug#6158: Theodor Rascanu

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.