emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Font lock for #if 0 ... #endif


From: martin rudalics
Subject: Re: Font lock for #if 0 ... #endif
Date: Tue, 29 May 2007 14:29:31 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> Martin, how about extending hideif to allow this as an option?  It
> sounds like a good feature.

Please have a look at the attached patch.
*** progmodes/hideif.el Tue Jan 23 06:41:08 2007
--- progmodes/hideif.el Tue May 29 14:13:08 2007
***************
*** 242,250 ****
      (end-of-line 2)))
  
  (defun hide-ifdef-region-internal (start end)
!   (remove-overlays start end 'invisible 'hide-ifdef)
    (let ((o (make-overlay start end)))
!     (overlay-put o 'invisible 'hide-ifdef)))
  
  (defun hide-ifdef-region (start end)
    "START is the start of a #if or #else form.  END is the ending part.
--- 242,253 ----
      (end-of-line 2)))
  
  (defun hide-ifdef-region-internal (start end)
!   (remove-overlays start end 'hide-ifdef t)
    (let ((o (make-overlay start end)))
!     (overlay-put o 'hide-ifdef t)
!     (if hide-ifdef-shadow
!       (overlay-put o 'face 'hide-ifdef-shadow)
!       (overlay-put o 'invisible 'hide-ifdef))))
  
  (defun hide-ifdef-region (start end)
    "START is the start of a #if or #else form.  END is the ending part.
***************
*** 256,262 ****
  
  (defun hif-show-ifdef-region (start end)
    "Everything between START and END is made visible."
!   (remove-overlays start end 'invisible 'hide-ifdef))
  
  
  ;;===%%SF%% evaluation (Start)  ===
--- 259,265 ----
  
  (defun hif-show-ifdef-region (start end)
    "Everything between START and END is made visible."
!   (remove-overlays start end 'hide-ifdef t))
  
  
  ;;===%%SF%% evaluation (Start)  ===
***************
*** 726,736 ****
  
  (defun hif-hide-line (point)
    "Hide the line containing point.  Does nothing if `hide-ifdef-lines' is 
nil."
!   (if hide-ifdef-lines
!       (save-excursion
!       (goto-char point)
!       (hide-ifdef-region-internal (line-beginning-position)
!                                   (progn (hif-end-of-line) (point))))))
  
  
  ;;;  Hif-Possibly-Hide
--- 729,739 ----
  
  (defun hif-hide-line (point)
    "Hide the line containing point.  Does nothing if `hide-ifdef-lines' is 
nil."
!   (when hide-ifdef-lines
!     (save-excursion
!       (goto-char point)
!       (hide-ifdef-region-internal
!        (line-beginning-position) (progn (hif-end-of-line) (point))))))
  
  
  ;;;  Hif-Possibly-Hide
***************
*** 815,836 ****
  
  ;;;###autoload
  (defcustom hide-ifdef-initially nil
!   "*Non-nil means call `hide-ifdefs' when Hide-Ifdef mode is first activated."
    :type 'boolean
    :group 'hide-ifdef)
  
  ;;;###autoload
  (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)
  
  ;;;###autoload
  (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'."
    (interactive)
--- 818,849 ----
  
  ;;;###autoload
  (defcustom hide-ifdef-initially nil
!   "Non-nil means call `hide-ifdefs' when Hide-Ifdef mode is first activated."
    :type 'boolean
    :group 'hide-ifdef)
  
  ;;;###autoload
  (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)
  
  ;;;###autoload
  (defcustom hide-ifdef-lines nil
!   "Non-nil means hide the #ifX, #else, and #endif lines."
    :type 'boolean
    :group 'hide-ifdef)
  
+ ;;;###autoload
+ (defcustom hide-ifdef-shadow nil
+   "Non-nil means shadow text instead of hiding it."
+   :type 'boolean
+   :group 'hide-ifdef)
+ 
+ (defface hide-ifdef-shadow '((t (:inherit shadow)))
+   "Face for shadowing ifdef blocks."
+   :group 'hide-ifdef)
+ 
  (defun hide-ifdef-toggle-read-only ()
    "Toggle `hide-ifdef-read-only'."
    (interactive)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]