]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/hideif.el
(bdf-generate-font): New argument CHARSET. Give WIDTH
[gnu-emacs] / lisp / progmodes / hideif.el
index 4179c9032759631b879903c24890c47343275c2c..d746c0ca4414ac9282768e724e618bf7cfb4bc3f 100644 (file)
 
 (require 'cc-mode)
 
+(defgroup hide-ifdef nil
+  "Hide selected code within `ifdef'."
+  :group 'c)
+
 (defvar hide-ifdef-mode-submap nil
   "Keymap used with Hide-Ifdef mode.")
 
@@ -351,7 +355,7 @@ that form should be displayed.")
 
 ; pattern to match initial identifier, !, &&, ||, (, or ).
 ; Added ==, + and -: garyo@avs.com 8/9/94
-(defconst hif-token-regexp "^\\(!\\|&&\\|||\\|[!=]=\\|[()+-]\\|\\w+\\)")
+(defconst hif-token-regexp "^\\(&&\\|||\\|[!=]=\\|!\\|[()+-]\\|[<>]=?\\|\\w+\\)")
 (defconst hif-end-of-comment "\\*/")
 
 
@@ -403,6 +407,10 @@ that form should be displayed.")
                        ((string-equal token "defined") 'hif-defined)
                        ((string-equal token "(") 'lparen)
                        ((string-equal token ")") 'rparen)
+                       ((string-equal token ">") 'hif-greater)
+                       ((string-equal token "<") 'hif-less)
+                       ((string-equal token ">=") 'hif-greater-equal)
+                       ((string-equal token "<=") 'hif-less-equal)
                        ((string-equal token "+") 'hif-plus)
                        ((string-equal token "-") 'hif-minus)
                        (t (intern token)))
@@ -448,10 +456,11 @@ that form should be displayed.")
     result))
 
 (defun hif-eq-expr ()
-  "Parse an eq-expr : math | eq-expr '=='|'!=' math."
+  "Parse an eq-expr : math | eq-expr `=='|`!='|`<'|`>'|`>='|`<=' math."
   (let ((result (hif-math))
        (eq-token nil))
-    (while (or (eq token 'equal) (eq token 'hif-notequal))
+    (while (memq token '(equal hif-notequal hif-greater hif-less
+                              hif-greater-equal hif-less-equal))
       (setq eq-token token)
       (hif-nexttoken)
       (setq result (list eq-token result (hif-math))))
@@ -524,7 +533,18 @@ that form should be displayed.")
 (defun hif-notequal (a b)
   "Like (not (equal A B)) but as one symbol."
   (not (equal a b)))
-
+(defun hif-greater (a b)
+  "Simple comparison."
+  (> (hif-mathify a) (hif-mathify b)))
+(defun hif-less (a b)
+  "Simple comparison."
+  (< (hif-mathify a) (hif-mathify b)))
+(defun hif-greater-equal (a b)
+  "Simple comparison."
+  (>= (hif-mathify a) (hif-mathify b)))
+(defun hif-less-equal (a b)
+  "Simple comparison."
+  (<= (hif-mathify a) (hif-mathify b)))
 ;;;----------- end of parser -----------------------
 
 
@@ -870,19 +890,25 @@ It does not do the work that's pointless to redo on a recursive entry."
 ;===%%SF%% exports (Start)  ===
 
 ;;;###autoload
-(defvar hide-ifdef-initially nil
-  "*Non-nil means call `hide-ifdefs' when Hide-Ifdef mode is first activated.")
+(defcustom hide-ifdef-initially nil
+  "*Non-nil means call `hide-ifdefs' when Hide-Ifdef mode is first activated."
+  :type 'boolean
+  :group 'hide-ifdef)
 
 ;;;###autoload
-(defvar hide-ifdef-read-only nil
-  "*Set to non-nil if you want buffer to be read-only while hiding text.")
+(defcustom hide-ifdef-read-only nil
+  "*Set to non-nil if you want buffer to be read-only while hiding text."
+  :type 'boolean
+  :group 'hide-ifdef)
 
 (defvar hif-outside-read-only nil
   "Internal variable.  Saves the value of `buffer-read-only' while hiding.")
 
 ;;;###autoload
-(defvar hide-ifdef-lines nil
-  "*Non-nil means hide the #ifX, #else, and #endif lines.")
+(defcustom hide-ifdef-lines nil
+  "*Non-nil means hide the #ifX, #else, and #endif lines."
+  :type 'boolean
+  :group 'hide-ifdef)
 
 (defun hide-ifdef-toggle-read-only ()
   "Toggle hide-ifdef-read-only."