unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Martin Slouf <mar@centrum.cz>
Subject: Re: Need help writing file-visiting macro
Date: Tue, 26 Jul 2005 20:24:23 +0200	[thread overview]
Message-ID: <20050726182423.GA7835@barbucha.martin.net> (raw)
In-Reply-To: <dc5m7f$nm6$1@sea.gmane.org>

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)).
> 

      reply	other threads:[~2005-07-26 18:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-25 13:58 Need help writing file-visiting macro Roy Smith
2005-07-25 15:33 ` Thien-Thi Nguyen
2005-07-25 16:45   ` Roy Smith
2005-07-25 17:44     ` drkm
2005-07-25 16:50 ` Sergei Organov
2005-07-25 17:52 ` rgb
2005-07-25 21:02   ` drkm
2005-07-26 22:49     ` rgb
2005-07-25 18:05 ` Kevin Rodgers
2005-07-25 21:38 ` Martin Slouf
2005-07-26 15:52   ` Kevin Rodgers
2005-07-26 18:24     ` Martin Slouf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050726182423.GA7835@barbucha.martin.net \
    --to=mar@centrum.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).