From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-15?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: Low level trickery for changing character syntax? Date: Tue, 08 Apr 2014 19:49:16 +0200 Message-ID: <5344369C.5060201@easy-emacs.de> References: <87lhvfzrgt.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1396979103 4914 80.91.229.3 (8 Apr 2014 17:45:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Apr 2014 17:45:03 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 08 19:44:54 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 1WXa4r-0002o9-Bi for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Apr 2014 19:44:53 +0200 Original-Received: from localhost ([::1]:42238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXa4r-0000Eg-0f for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Apr 2014 13:44:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXa4Y-0000Dh-Fe for help-gnu-emacs@gnu.org; Tue, 08 Apr 2014 13:44:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXa4Q-0005Yh-Nr for help-gnu-emacs@gnu.org; Tue, 08 Apr 2014 13:44:34 -0400 Original-Received: from moutng.kundenserver.de ([212.227.126.130]:52047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXa4Q-0005YT-Cv for help-gnu-emacs@gnu.org; Tue, 08 Apr 2014 13:44:26 -0400 Original-Received: from purzel.sitgens (brln-4d0c52b0.pool.mediaWays.net [77.12.82.176]) by mrelayeu.kundenserver.de (node=mreue006) with ESMTP (Nemesis) id 0LdyJ6-1XLAUG29yW-00pqZl; Tue, 08 Apr 2014 19:44:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <87lhvfzrgt.fsf@gmail.com> X-Provags-ID: V02:K0:MnxhtC1mLLlggSaHDAzM02ReJ9uCxk9Cr4L/nmwYQST jf6C4TvVd8hWRpu/lujkC8OiagwATdDQXLkIkZOUWJYhs7NP20 lsiSXXnYMpi5Z22euvjeH5lt4Qzk7k0UPzSvDil9mVKZlOnEhm pAiWlQsoGN3Ibv6GW0UlfgTXTSC7qs+B1VVrfzOJj9QG8RQvq/ r27eZdFl2U1vyorh2dVBo76fIGLOz58OL1jZTgBy2VMW+0DbY7 ej3JcFJE82SDTi0uTehsFQ1BSBPsT+ORruWrMAx6d32OBcjEvx 2uE+gYc+zfgquaM635VwpWfZLkKRuEA4C3gA0g3BTYMDTElomP XqIYqbz1t12SrFc5iJhnbcKxkbF//V7uPbCyYU20K X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 212.227.126.130 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:97048 Archived-At: Am 08.04.2014 19:00, schrieb Thorsten Jolitz: > > Hi List, > > assume an imaginary elisp library gro.el I cannot (or don't want to) > change that is used on files of type A, with functions matching these > kinds of strings: > > #+begin_src emacs-lisp > (defconst rgxp-1 "^[*] [*]Fat[*]$") > > (defun foo (strg) > (and (string-match "^\\*+[ \t]* \\*.+\\*" strg) > (string-match rgxp-1 strg))) > #+end_src > > #+results: > : foo > > #+begin_src emacs-lisp > (foo "* *Fat*") > #+end_src > > #+results: > : 0 > > #+begin_src emacs-lisp > (foo "+ *Fat*") > #+end_src > > #+results: > > Now assume I want to use gro.el functionality on files of type B > such that it matches strings likes this: > > #+begin_src emacs-lisp > (foo "// # *Fat*//" ) > #+end_src > > In short, when called from file.type-A, I want foo to match "// # > *Fat*//", while it should only match "* *Fat*" when called from > file.type-B (without changing foo or rgxp-1). > > Thus in rgxp-1 and in foo, "^" would need to be replaced with "^// ", > the first "*" would need to be replaced with "#" (the other occurences > not), and "$" would need to be replaced with "//$". > > Now I wonder what would be the best way (or at least a possible way) to > achieve this with Emacs low-level trickery (almost) without touching > gro.el. I don't enough know about syntax table low-level stuff besides > reading the manual, so these are only vague speculations: > > 1. Change the syntax-table of gro.el whenever it is applied to files of > type B such that "^" is seen as "^// ", "*" as "#" etc.? > > 2. Define new categories and put "^" "*" and "$" in them, and somehow > load/activate these categories conditional on the type of file gro.el > functionality is called upon. These categories should then achieve that > "^" is seen as "^// " etc when the categories are loaded? > > 3. Define "^" and "$", when found at beg/end of a string, as 'generic > comment delimiter, and define "/" as generic comment delimiter too, such > that "^//" and "//$" are matched by "^" and "$"? > > I know that these ideas do not and cannot work as described, but I'm > looking for a hint which idea could possibly work? What would be the way > to go? > > Or is this completely unrealistic and the only way to achieve it is to > change the hardcoded regexps in (imaginary) library gro.el? > Possible is a lot, the easiest IMO would be switching the regexp if A-type: ... if B-type: