From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Martin Slouf Newsgroups: gmane.emacs.help Subject: Re: Need help writing file-visiting macro Date: Tue, 26 Jul 2005 20:24:23 +0200 Message-ID: <20050726182423.GA7835@barbucha.martin.net> References: <20050725212531.GC9300@barbucha.martin.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1122402365 22116 80.91.229.2 (26 Jul 2005 18:26:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 26 Jul 2005 18:26:05 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 26 20:26:03 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DxU79-0007PF-Ms for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Jul 2005 20:25:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DxU9V-0004HF-R8 for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Jul 2005 14:27:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DxU9F-0004Gp-AK for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 14:27:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DxU9D-0004G0-VU for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 14:27:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DxU9D-0004Fo-Qn for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 14:27:23 -0400 Original-Received: from [84.242.95.145] (helo=barbucha.martin.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DxUH8-0000Dx-1A for help-gnu-emacs@gnu.org; Tue, 26 Jul 2005 14:35:34 -0400 Original-Received: from martin by barbucha.martin.net with local (Exim 3.36 #1 (Debian)) id 1DxU6J-00024l-00 for ; Tue, 26 Jul 2005 20:24:23 +0200 Original-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i 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:28208 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:28208 thanks a lot for the hint, Kevin. i spend some time watching those functions and a finally read some basic chapters from elisp manual to understand it a bit more. It is not so bad as I thought it would be. martin On Tue, Jul 26, 2005 at 09:52:13AM -0600, Kevin Rodgers wrote: > 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)). >