From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Need help writing file-visiting macro Date: Tue, 26 Jul 2005 09:52:13 -0600 Message-ID: References: <20050725212531.GC9300@barbucha.martin.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1122394324 28587 80.91.229.2 (26 Jul 2005 16:12:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 26 Jul 2005 16:12:04 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 26 18:12:02 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DxRzv-0003gU-MH for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Jul 2005 18:09:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DxS2H-0005cQ-9J for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Jul 2005 12:12:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DxRyN-0004DU-4B for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 12:08:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DxRyH-0004B9-1a for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 12:07:58 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DxRyF-0003x0-PR for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 12:07:55 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DxRvI-00065H-Jz for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 12:04:52 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1DxRjM-0000Lp-5r for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 17:52:32 +0200 Original-Received: from 207.167.42.60 ([207.167.42.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Jul 2005 17:52:32 +0200 Original-Received: from ihs_4664 by 207.167.42.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Jul 2005 17:52:32 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 84 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.60 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: <20050725212531.GC9300@barbucha.martin.net> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:28201 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28201 Martin Slouf wrote: > Is there an easy modification of this piece of code that can help me to find > files in different directories? i guess these are the string manipulation > functions. There are also file name manipulation functions, which are generally preferable to the lower-level string manipulation functions: file-name-directory file-name-nondirectory file-name-extension file-name-sans-extension file-name-sans-versions file-name-as-directory directory-file-name expand-file-name > The situation is like this: > > For each business level class (BankAccount.java) (located somewhere under the > 'src' directory structure) there are at least two jsp pages: > bank_account_edit_.jsp and bank_account_list_.jsp under the 'web' directory > structure), ie: > > top dir > + > | > +-- src (Java source in packages) > | | > | +-- somewhere > | | > | +-- BankAccount.java > | > +---web (JSP pages using jakarta-struts) > | > +-- somewhere > | > +-- bank_account_edit_.jsp > | > +-- bak_account_list_.jsp > > > i get those macros (proposed in thi sthread) open the same buffer with > modified name in the same directory. My questions are like this: > > 1. what string function can be used to make the string BankAccount to > transform it into bank_account_edit_ and bank_account_list_ Hmmm, CamelCase to lower_case. http://www.emacswiki.org/cgi-bin/wiki/CamelCase refers to glasses-mode, which unfortunately doesn't provide a low level utility function to convert strings. But you can write your own: (defun CamelCase-to-lower_case (string) (let ((i 0) (result "") (case-fold-search nil)) (while (string-match "[[:upper:]][[:lower:]]*" string i) (setq result (concat result (substring string i (match-beginning 0)) (if (> (match-beginning 0) 0) "_") (downcase (match-string 0 string)))) (setq i (match-end 0))) (setq result (concat result (substring string i))))) So (concat (CamelCase-to-lower_case "BankAccount") "_edit_") returns "bank_account_edit_". > 2. what functions should be used to open those jsp buffers (java > buffer respectively)?, when each of this file is / can be in different > directory? Just stick with find-file, or perhaps (switch-to-buffer (find-file-noselect FILE)) or (pop-to-buffer (find-file-noselect FILE)). -- Kevin Rodgers