From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jacob Gerlach Newsgroups: gmane.emacs.help Subject: List-of-lists data structure Date: Sat, 12 Apr 2014 09:46:47 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1397327501 24390 80.91.229.3 (12 Apr 2014 18:31:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Apr 2014 18:31:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 12 20:31:34 2014 Return-path: Envelope-to: geh-help-gnu-emacs@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 1WZ2iA-0007yV-Ka for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Apr 2014 20:31:30 +0200 Original-Received: from localhost ([::1]:35314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ2i9-0006b5-GI for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Apr 2014 14:31:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYyGg-0006tO-Sg for help-gnu-emacs@gnu.org; Sat, 12 Apr 2014 09:46:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYyGf-0004XB-Iy for help-gnu-emacs@gnu.org; Sat, 12 Apr 2014 09:46:50 -0400 Original-Received: from mail-lb0-x231.google.com ([2a00:1450:4010:c04::231]:38089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYyGf-0004Tc-6E for help-gnu-emacs@gnu.org; Sat, 12 Apr 2014 09:46:49 -0400 Original-Received: by mail-lb0-f177.google.com with SMTP id z11so4293571lbi.8 for ; Sat, 12 Apr 2014 06:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=JrV2YA7hxx291UXNUNTGb+85UGN7cDh4WJG+gIlQ/mU=; b=pdhazK6d0A8RWf+oLNaymD8IWLMJqxH7vP9v9k87zbadEHyrlXTsHe/GdfRgO1Qayx w5H8t+16kaRaskOlkyRUaL8AVt6gfr6NBwt5Ev49y97dPbJCYgmTGP/8m0B1mOqmOFfB gYgE3yUQ1bIdMJ6GBGke04wjsskRnf7fPEt7FdgpfEjacyn1s0ytcwmV882vrJa3uhaf ClfquE/K8rU5xvJtX4NKA6fiPTMkaV/sYK2bL7i1Mlx4Cw8SWHl7UcscyZXf1Ok/VjCu RiDH3y1M/bZ65SFBk4m3/2bNZrbJWcolqGb2YWtUEjSJqpmvkMl4dMNtAJMy9UEyTGNi gWAA== X-Received: by 10.112.142.68 with SMTP id ru4mr142506lbb.49.1397310407345; Sat, 12 Apr 2014 06:46:47 -0700 (PDT) Original-Received: by 10.114.22.227 with HTTP; Sat, 12 Apr 2014 06:46:47 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::231 X-Mailman-Approved-At: Sat, 12 Apr 2014 14:31:21 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97108 Archived-At: I'm working on implementing fontification in a major mode for an in house scripting language. The scripts configure any of about 50 different apps, each of which has different keywords. This looks something like: -------------------------------- processConfig = pFoo { foo = 1 bar = true baz = normal } processConfig = pBar { apples = foo pears = bar oranges = false } --------------------------------- Only the names on the left of the equals are keywords, so foo and bar should receive the appropriate font lock face in the pFoo block, but not in the pBar block (where apples, pears, and oranges would be font-locked). I have managed to make fontification app specific using multiline font lock matching and regexp's anchored to "processConfig = pFoo" (for example). In the interest of long term maintainability, I want to create a data structure to store all of the app names and associated keywords, which I then iterate through to generate the entries for the fontification keyword list. For one app, I can use: (setq name-and-keyword-list '("pFoo" ("foo" "bar" "baz"))) This gives me the ability to do something like: (while foo (add-to-list 'my-app-names (car foo)) (add-to-list 'my-keywords (make-font-lock-cons (car foo) (cdr foo))) (setq foo (cdr foo))) Where make-font-lock-cons is a hypothetical function that returns the appropriate cons cell for my keyword list, which uses the app name (the car) as the anchor, and uses regexp-opt to generate a regexp for actually matching using the list of keywords (the cdr). This works for my one entry list - at least, (car name-and-keyword-list) and (cdr name-and-keyword-list) give me what I would expect. However, if I try to expand the list: (setq name-and-keyword-list '("pFoo" ("foo" "bar" "baz")) '("pBar" ("apples" "pears" "orange"))) Building the list gives: Wrong type argument: symbolp, (quote ("pBar" ("apples" "pears" "orange"))) Is this a simple syntax error, or am I approaching this data structure in the wrong way? Any other recommendations on my approach to this problem would be very welcome. Thanks, Jake