tag:blogger.com,1999:blog-3669809752172683097.post1424528947592606899..comments2024-02-08T04:04:28.385-08:00Comments on Cyclopedia Square: Highlight "#if 0" Region of C, C++Bryanhttp://www.blogger.com/profile/11394436715172971234noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-3669809752172683097.post-67092160624867596662007-06-01T12:03:00.000-07:002007-06-01T12:03:00.000-07:00The following is from my .emacs for my old snapsho...The following is from my .emacs for my old snapshot of emacs 22. Note that it isn't perfect - you must recenter the buffer to get the highlighting to update after it's changed.<BR/>I'd rather have this functionality part of font-lock but this is really over my head. <BR/><BR/>;; ------------ C Mode<BR/>(defun my-cpp-highlight ()<BR/> (setq cpp-known-face '(background-color . "dim gray"))<BR/> (setq cpp-unknown-face 'default)<BR/> (setq cpp-face-type 'dark)<BR/> (setq cpp-known-writable 't)<BR/> (setq cpp-unknown-writable 't)<BR/> (setq cpp-edit-list<BR/> '((#("0" 0 1<BR/> (c-in-sws t fontified t))<BR/> (background-color . "dim gray")<BR/> nil both nil)<BR/> (#("1" 0 1<BR/> (c-in-sws t fontified t))<BR/> nil<BR/> (background-color . "dim gray")<BR/> both nil)))<BR/> (cpp-highlight-buffer t))<BR/><BR/>(defun my-c-mode-common-hook ()<BR/> (my-cpp-highlight)<BR/> )<BR/><BR/>(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)<BR/><BR/>(defun my-c-mode-recenter ()<BR/> "Recenter buffer and refresh highlighting."<BR/> (interactive)<BR/> (recenter)<BR/> (cpp-highlight-buffer t))<BR/><BR/>(defun my-c-initialization-hook ()<BR/> (define-key c-mode-base-map "\C-l" 'my-c-mode-recenter))<BR/><BR/>(add-hook 'c-initialization-hook 'my-c-initialization-hook)Zung!https://www.blogger.com/profile/07718442985309348694noreply@blogger.com