aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/progmodes/hideif.el87
2 files changed, 58 insertions, 45 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c6535b7f8dc..75771572cf9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,19 @@
12008-04-05 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/hideif.el (hif-token-alist): New var.
4 (hif-token-regexp, hif-tokenize): Use it.
5 (hif-mathify-binop): New macro.
6 (hif-plus, hif-minus, hif-notequal, hif-greater, hif-less)
7 (hif-greater-equal, hif-less-equal): Use it.
8 (hif-logior, hif-logand): New functions.
9 (hif-math): Accept | and & as well.
10
11 * progmodes/etags.el: Fix problem with completion for buffer-local
12 tables. Reported by Radey Shouman <shouman@comcast.net>.
13 (tags-complete-tag): Remove.
14 (tags-lazy-completion-table): New function to replace it.
15 (find-tag-tag, complete-tag): Update users.
16
12008-04-04 Dan Nicolaescu <dann@ics.uci.edu> 172008-04-04 Dan Nicolaescu <dann@ics.uci.edu>
2 18
3 * vc-rcs.el (vc-rcs-dir-status): 19 * vc-rcs.el (vc-rcs-dir-status):
diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el
index 83ffb5f7a0e..5c9bf45e392 100644
--- a/lisp/progmodes/hideif.el
+++ b/lisp/progmodes/hideif.el
@@ -348,10 +348,27 @@ that form should be displayed.")
348(defvar hif-token) 348(defvar hif-token)
349(defvar hif-token-list) 349(defvar hif-token-list)
350 350
351;; pattern to match initial identifier, !, &&, ||, (, or ). 351(defconst hif-token-alist
352;; Added ==, + and -: garyo@avs.com 8/9/94 352 '(("||" . or)
353 ("&&" . and)
354 ("|" . hif-logior)
355 ("&" . hif-logand)
356 ("==" . equal)
357 ("!=" . hif-notequal)
358 ("!" . not)
359 ("(" . lparen)
360 (")" . rparen)
361 (">" . hif-greater)
362 ("<" . hif-less)
363 (">=" . hif-greater-equal)
364 ("<=" . hif-less-equal)
365 ("+" . hif-plus)
366 ("-" . hif-minus)
367 ("?" . hif-conditional)
368 (":" . hif-colon)))
369
353(defconst hif-token-regexp 370(defconst hif-token-regexp
354 "\\(&&\\|||\\|[!=]=\\|!\\|[()+?:-]\\|[<>]=?\\|\\w+\\)") 371 (concat (regexp-opt (mapcar 'car hif-token-alist)) "\\|\\w+"))
355 372
356(defun hif-tokenize (start end) 373(defun hif-tokenize (start end)
357 "Separate string between START and END into a list of tokens." 374 "Separate string between START and END into a list of tokens."
@@ -369,26 +386,11 @@ that form should be displayed.")
369 (let ((token (buffer-substring (point) (match-end 0)))) 386 (let ((token (buffer-substring (point) (match-end 0))))
370 (goto-char (match-end 0)) 387 (goto-char (match-end 0))
371 ;; (message "token: %s" token) (sit-for 1) 388 ;; (message "token: %s" token) (sit-for 1)
372 (push (cond 389 (push (or (cdr (assoc token hif-token-alist))
373 ((string-equal token "||") 'or) 390 (if (string-equal token "defined") 'hif-defined)
374 ((string-equal token "&&") 'and) 391 (if (string-match "\\`[0-9]*\\'" token)
375 ((string-equal token "==") 'equal) 392 (string-to-number token))
376 ((string-equal token "!=") 'hif-notequal) 393 (intern token))
377 ((string-equal token "!") 'not)
378 ((string-equal token "defined") 'hif-defined)
379 ((string-equal token "(") 'lparen)
380 ((string-equal token ")") 'rparen)
381 ((string-equal token ">") 'hif-greater)
382 ((string-equal token "<") 'hif-less)
383 ((string-equal token ">=") 'hif-greater-equal)
384 ((string-equal token "<=") 'hif-less-equal)
385 ((string-equal token "+") 'hif-plus)
386 ((string-equal token "-") 'hif-minus)
387 ((string-equal token "?") 'hif-conditional)
388 ((string-equal token ":") 'hif-colon)
389 ((string-match "\\`[0-9]*\\'" token)
390 (string-to-number token))
391 (t (intern token)))
392 token-list))) 394 token-list)))
393 (t (error "Bad #if expression: %s" (buffer-string))))))) 395 (t (error "Bad #if expression: %s" (buffer-string)))))))
394 (nreverse token-list))) 396 (nreverse token-list)))
@@ -457,7 +459,7 @@ that form should be displayed.")
457 math : factor | math '+|-' factor." 459 math : factor | math '+|-' factor."
458 (let ((result (hif-factor)) 460 (let ((result (hif-factor))
459 (math-op nil)) 461 (math-op nil))
460 (while (memq hif-token '(hif-plus hif-minus)) 462 (while (memq hif-token '(hif-plus hif-minus hif-logior hif-logand))
461 (setq math-op hif-token) 463 (setq math-op hif-token)
462 (hif-nexttoken) 464 (hif-nexttoken)
463 (setq result (list math-op result (hif-factor)))) 465 (setq result (list math-op result (hif-factor))))
@@ -515,27 +517,22 @@ that form should be displayed.")
515 (or (not (zerop (hif-mathify a))) (not (zerop (hif-mathify b))))) 517 (or (not (zerop (hif-mathify a))) (not (zerop (hif-mathify b)))))
516(defun hif-not (a) 518(defun hif-not (a)
517 (zerop (hif-mathify a))) 519 (zerop (hif-mathify a)))
518(defun hif-plus (a b) 520
519 "Like ordinary plus but treat t and nil as 1 and 0." 521(defmacro hif-mathify-binop (fun)
520 (+ (hif-mathify a) (hif-mathify b))) 522 `(lambda (a b)
521(defun hif-minus (a b) 523 ,(format "Like `%s' but treat t and nil as 1 and 0." fun)
522 "Like ordinary minus but treat t and nil as 1 and 0." 524 (,fun (hif-mathify a) (hif-mathify b))))
523 (- (hif-mathify a) (hif-mathify b))) 525
524(defun hif-notequal (a b) 526(defalias 'hif-plus (hif-mathify-binop +))
525 "Like (not (equal A B)) but as one symbol." 527(defalias 'hif-minus (hif-mathify-binop -))
526 (not (equal a b))) 528(defalias 'hif-notequal (hif-mathify-binop /=))
527(defun hif-greater (a b) 529(defalias 'hif-greater (hif-mathify-binop >))
528 "Simple comparison." 530(defalias 'hif-less (hif-mathify-binop <))
529 (> (hif-mathify a) (hif-mathify b))) 531(defalias 'hif-greater-equal (hif-mathify-binop >=))
530(defun hif-less (a b) 532(defalias 'hif-less-equal (hif-mathify-binop <=))
531 "Simple comparison." 533(defalias 'hif-logior (hif-mathify-binop logior))
532 (< (hif-mathify a) (hif-mathify b))) 534(defalias 'hif-logand (hif-mathify-binop logand))
533(defun hif-greater-equal (a b) 535
534 "Simple comparison."
535 (>= (hif-mathify a) (hif-mathify b)))
536(defun hif-less-equal (a b)
537 "Simple comparison."
538 (<= (hif-mathify a) (hif-mathify b)))
539;;;----------- end of parser ----------------------- 536;;;----------- end of parser -----------------------
540 537
541 538