From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?QW5kcmVhcyBSw7ZobGVy?= Newsgroups: gmane.emacs.help Subject: Re: lisp file to modify contents of project Date: Sat, 12 Nov 2011 13:46:23 +0100 Message-ID: <4EBE6A9F.3080302@easy-emacs.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1321102007 23036 80.91.229.12 (12 Nov 2011 12:46:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 12 Nov 2011 12:46:47 +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 Nov 12 13:46:43 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RPCyo-0002rR-8l for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Nov 2011 13:46:42 +0100 Original-Received: from localhost ([::1]:45982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPCyn-0008W2-PD for geh-help-gnu-emacs@m.gmane.org; Sat, 12 Nov 2011 07:46:41 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:56311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPCyi-0008Vh-Gv for help-gnu-emacs@gnu.org; Sat, 12 Nov 2011 07:46:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPCyf-0001ad-NI for help-gnu-emacs@gnu.org; Sat, 12 Nov 2011 07:46:36 -0500 Original-Received: from moutng.kundenserver.de ([212.227.17.10]:57552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPCyf-0001aB-87 for help-gnu-emacs@gnu.org; Sat, 12 Nov 2011 07:46:33 -0500 Original-Received: from [192.168.178.27] (brln-4d0c22ad.pool.mediaWays.net [77.12.34.173]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MEJOW-1R9mda00Pg-00Fwxw; Sat, 12 Nov 2011 13:46:30 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.23) Gecko/20110920 SUSE/3.1.15 Thunderbird/3.1.15 In-Reply-To: X-Provags-ID: V02:K0:XiTksl8PCLOioYBqPgZD0H6DXfSGCwV4j2ZGb/jDUhP YUgH7qpMj8zuX2KDkYwKMal8jKL7ZPCEWJlzZyGOQ8ol4TIUl4 igqNuDzGFlmyiKHeNM1KHRQEhub9DN0ZSjoVogU3Z9iaFVcPmg OQPSxG3TLooeIqwWbXKy56T245TI6Oh56O9MHb/NC7aM2kJyG1 gRBREGmMCtN6+obnfzeICfD3dEzg3XDOBLtShguDEjIdtrYJG8 6QyT1p5nERx8GHaHM0jt0m9KQYkpmnDyLb1IYBYDCJnWZ/s4yN xlCTHwHm6aJoIU8lwVTFcT6wZd37Mv5Y3DVL9nXnrxFd9sJt/c s/6It2G10esEvQB24SxMqIPk9VUu1W16BxLt13Lko X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.10 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:82877 Archived-At: Am 11.11.2011 10:49, schrieb David Belohrad: > Dear All, > > i'm not very experienced with elisp/emacs so any help here appreciated. > > Imagine that I have VHDL project consisting of may VHDL files, like e.g. > this one: > > ---------------------------------------------------------------- > library ieee; > use ieee.std_logic_1164.all; > use ieee.numeric_std.all; > use work.Types.all; > use work.bunch_storage.all; > > --! @brief bunch selection memory > --! @details implements 128x32 memory to store info about all the bunches > --! selected for the capture acquisition > entity bunch_selection_memory is > port (Clk120MHzxC : in std_logic; --! 120MHz clock > Reset120MHzxRN : in std_logic; --! 120MHz synced > reset > NumberOfBunchSlotsxD : in positive; --! number of bunch > slots derived from current timing and IsLHCTimingxS > BSELVmeMemDxD : in VLong; --! 16 bit word input to > the memory via VME interface > > and so on.......... > ------------------------------------------------------------------- > > this VHDL project is however defined as well in not-only-VHDL-files, but as > well e.g. mentor modelsim wave.do, containing commands like this one: > > ------------------------------------------------------------------- > add wave -noupdate -expand -group dut -format Logic -radix hexadecimal > /bunch_selection_memory_tb/dut/reset120mhzxrn > ------------------------------------------------------------------- > > or quartus setting file, containing settings like this one: > > ------------------------------------------------------------------ > set_location_assignment PIN_D11 -to Reset120MHzxRN > ------------------------------------------------------------------ > > > > Now I came into situation, that I have to rename the Reset120MHzxRN signal > into something completely different. So I was thinking just make dired of > VHDL/SETTING/MODELSIM files, and just replace Reset120MHzxRN by another > string. But I ran into troubles with caseness of the replace. I need that > in the VHDL and quartus setting file the case stays _exactly_ as is, > whereas in modelsim file I need to convert it into lowercase and replace > only lowercase occurence by another lowercase occurence. > > > > I don't think it is possible to use dired mode for this - except that I do > all the operation in two steps. Having quite a lot of these signals it is > not really wise. So I was thinking, whether it is feasible to do some lisp > code, which will: > > list all *.vhd, *.do, *.qsf from the project > do all the replacements as shown above. > > > is it feasible? the 'thing' i'm bit lost in is how to open make a list of > files universally (independent of whether win/lin), and how to generate > another buffer which would tell me what exactly in which file was changed > -> something like diff mode > > > any help appreciated.... > > thanks > d. > Just to send some start which should return a files list - approximately. Before running edit the default directory, called in code "auspack" - same with MY-TERM. (defun my-replace-start (&optional directory) (interactive) (let* ((dir (or directory (expand-file-name "~/auspack"))) erg) (setq erg (shell-command-to-string (concat "find " dir " -type f -name \"\*.vhf\" -o -type f -name \"\*.do\" -o -type f -name \"\*.qsf\" | xargs -0 -e grep -nH -e \"MY-TERM\""))) (when (interactive-p) (message "%s" erg)) erg)) Once the files list ready, something like that (dolist (ele liste) (find-file ele) (goto-char (point-min)) (while (re-search-forward "MY-EXPRESSION" nil (quote move) 1) (replace-match "MY-REPLACE")) (write-region... HTH Andreas