[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need help writing file-visiting macro
From: |
Martin Slouf |
Subject: |
Re: Need help writing file-visiting macro |
Date: |
Tue, 26 Jul 2005 20:24:23 +0200 |
User-agent: |
Mutt/1.5.9i |
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)).
>
- Re: Need help writing file-visiting macro, (continued)
- Re: Need help writing file-visiting macro, Thien-Thi Nguyen, 2005/07/25
- Re: Need help writing file-visiting macro, Sergei Organov, 2005/07/25
- Re: Need help writing file-visiting macro, rgb, 2005/07/25
- Re: Need help writing file-visiting macro, Kevin Rodgers, 2005/07/25
- Re: Need help writing file-visiting macro, Martin Slouf, 2005/07/25