X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/a113b3ca322fd73d97d0d9d69c9f48dc13fb326a..acaf905b1130aae80fa59d2c861ffd4c8eb75486:/lisp/progmodes/hideif.el diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el index b3551fefcd..3e3d7adc0b 100644 --- a/lisp/progmodes/hideif.el +++ b/lisp/progmodes/hideif.el @@ -1,18 +1,18 @@ ;;; hideif.el --- hides selected code within ifdef -;; Copyright (C) 1988, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, -;; 2008 Free Software Foundation, Inc. +;; Copyright (C) 1988, 1994, 2001-2012 Free Software Foundation, Inc. -;; Author: Daniel LaLiberte +;; Author: Brian Marick +;; Daniel LaLiberte ;; Maintainer: FSF ;; Keywords: c, outlines ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,9 +20,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -216,11 +214,15 @@ ;;;###autoload (define-minor-mode hide-ifdef-mode - "Toggle Hide-Ifdef mode. This is a minor mode, albeit a large one. -With ARG, turn Hide-Ifdef mode on if arg is positive, off otherwise. -In Hide-Ifdef mode, code within #ifdef constructs that the C preprocessor -would eliminate may be hidden from view. Several variables affect -how the hiding is done: + "Toggle features to hide/show #ifdef blocks (Hide-Ifdef mode). +With a prefix argument ARG, enable Hide-Ifdef mode if ARG is +positive, and disable it otherwise. If called from Lisp, enable +the mode if ARG is omitted or nil. + +Hide-Ifdef mode is a buffer-local minor mode for use with C and +C-like major modes. When enabled, code within #ifdef constructs +that the C preprocessor would eliminate may be hidden from view. +Several variables affect how the hiding is done: `hide-ifdef-env' An association list of defined and undefined symbols for the @@ -414,13 +416,14 @@ that form should be displayed.") "Pop the next token from token-list into the let variable \"hif-token\"." (setq hif-token (pop hif-token-list))) -(defun hif-parse-if-exp (hif-token-list) +(defun hif-parse-if-exp (token-list) "Parse the TOKEN-LIST. Return translated list in prefix form." - (hif-nexttoken) - (prog1 - (hif-expr) - (if hif-token ; is there still a token? - (error "Error: unexpected token: %s" hif-token)))) + (let ((hif-token-list token-list)) + (hif-nexttoken) + (prog1 + (hif-expr) + (if hif-token ; is there still a token? + (error "Error: unexpected token: %s" hif-token))))) (defun hif-expr () "Parse an expression as found in #if. @@ -509,7 +512,7 @@ that form should be displayed.") ;; Unary plus/minus. ((memq hif-token '(hif-minus hif-plus)) (list (prog1 hif-token (hif-nexttoken)) 0 (hif-factor))) - + (t ; identifier (let ((ident hif-token)) (if (memq ident '(or and)) @@ -761,7 +764,7 @@ Point is left unchanged." (cond ((hif-looking-at-else) (setq else (point))) (t - (setq end (point)))) ; (save-excursion (end-of-line) (point)) + (setq end (point)))) ; (line-end-position) ;; If found #else, look for #endif. (when else (while (progn @@ -770,7 +773,7 @@ Point is left unchanged." (hif-ifdef-to-endif)) (if (hif-looking-at-else) (error "Found two elses in a row? Broken!")) - (setq end (point))) ; (save-excursion (end-of-line) (point)) + (setq end (point))) ; (line-end-position) (hif-make-range start end else)))) @@ -819,7 +822,7 @@ Point is left unchanged." (defun hif-possibly-hide () "Called at #ifX expression, this hides those parts that should be hidden. -It uses the judgement of `hide-ifdef-evaluator'." +It uses the judgment of `hide-ifdef-evaluator'." ;; (message "hif-possibly-hide") (sit-for 1) (let ((test (hif-canonicalize)) (range (hif-find-range))) @@ -1026,5 +1029,4 @@ Return as (TOP . BOTTOM) the extent of ifdef block." (provide 'hideif) -;; arch-tag: c6381d17-a59a-483a-b945-658f22277981 ;;; hideif.el ends here