From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Fwd: Update earlier posted hideif.el enhancements Date: Fri, 29 Nov 2013 16:59:55 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1385762408 19362 80.91.229.3 (29 Nov 2013 22:00:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 Nov 2013 22:00:08 +0000 (UTC) Cc: emacs-devel@gnu.org To: Luke Lee Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 29 23:00:14 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VmW6f-0006Fn-MB for ged-emacs-devel@m.gmane.org; Fri, 29 Nov 2013 23:00:13 +0100 Original-Received: from localhost ([::1]:49783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmW6f-0001fj-BZ for ged-emacs-devel@m.gmane.org; Fri, 29 Nov 2013 17:00:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmW6T-0001UC-TW for emacs-devel@gnu.org; Fri, 29 Nov 2013 17:00:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VmW6O-0004FO-Hc for emacs-devel@gnu.org; Fri, 29 Nov 2013 17:00:01 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:53126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmW6O-0004FH-Cy for emacs-devel@gnu.org; Fri, 29 Nov 2013 16:59:56 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFHO+KEh/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kE4gLBsEtjRmDcQOIYZwZgV6DFYFI X-IPAS-Result: Av4EABK/CFHO+KEh/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kE4gLBsEtjRmDcQOIYZwZgV6DFYFI X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="40722632" Original-Received: from 206-248-161-33.dsl.teksavvy.com (HELO pastel.home) ([206.248.161.33]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 29 Nov 2013 16:59:55 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 29FBB60EFA; Fri, 29 Nov 2013 16:59:55 -0500 (EST) In-Reply-To: (Luke Lee's message of "Mon, 25 Nov 2013 14:35:27 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:165904 Archived-At: > Sure, no problem. Attached is the patch against Emacs trunk. Thanks. Came through unadulterated ;-) > I'm using git://git.savannah.gnu.org/emacs.git as my Emacs remote > source. I've checked the trunk, master and emacs-24 and they seems to > have the identical hideif.el version so I think it should be okay to > patch it. Indeed, there's been no real development on it in recently. See my comments below. Overall, I think it looks good and could be included in hideif.el, but I'd appreciate if you could clean up a few things first and split the change into a few chunks (this is a bit large to review as one single chunk). IIUC one chunk would focus on extend the current parser & evaluator to handle the full CPP syntax. Stefan > (if hide-ifdef-mode > (progn > ;; inherit global values > - (set (make-local-variable 'hide-ifdef-env) > - (default-value 'hide-ifdef-env)) > +;; (set (make-local-variable 'hide-ifdef-env) ;; [2012-09-27 11:05:26 +0800] Luke rem 2 ins 2 > +;; (default-value 'hide-ifdef-env)) > + (set 'hide-ifdef-env (default-value 'hide-ifdef-env)) > (set (make-local-variable 'hide-ifdef-hiding) > (default-value 'hide-ifdef-hiding)) > (set (make-local-variable 'hif-outside-read-only) buffer-read-only) I don't undertand this change. "(set ' ...)" is just a bad form of (setq ...) so use `setq' instead. > +(defun merge-ifdef-region (start end) This lacks the "hif-" or "hide-ifdef-" prefix. > ;;;----------------------------------------------------------------- > ;;; Translate C preprocessor #if expressions using recursive descent. > ;;; This parser is limited to the operators &&, ||, !, and "defined". > ;;; Added ==, !=, +, and -. Gary Oberbrunner, garyo@avs.com, 8/9/94 > +;;; > +;;; Implement the C language operator precedence table. Add all those > +;;; missing operators that could be used in macros. Luke Lee 2013-09-04 ";;;" should be limited to headers. The pre-existing code is already at fault, but we should fix the pre-existing code rather than repeating its mistake. > +;;; | Unary Operators | * & + - ! ~ ++expr --expr (typecast) sizeof | right-to-left | Try really hard to stay within 80 columns, please. > +(defun hif-expand-token-list (tokens &optional macroname reflist) ;; reference list to prevent self-referencing Same here. Also, we like to capitalize our comments and terminate them with full-stops. BTW, maybe we could/should add some code to smie.el so as to not only skip a expression but return a parse tree. Then we could use maybe it here. > +(defun shiftleft (a b) > +(defun shiftright (a b) > +(defun flatten (l) > +(defun delimit (l a) Lack the "hif-" prefix.