unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: extract regexp
Date: Tue, 22 Apr 2003 10:28:40 -0600	[thread overview]
Message-ID: <3EA56DB8.3090909@yahoo.com> (raw)
In-Reply-To: A1cpa.15474$J17.7232@twister.nyc.rr.com

Bruce Ingalls wrote:

> Thanks for your help. This is what I ended up with:
> 
> (setq moz-prefs-filename
>     "~/.mozilla/...[random name].../default/prefs.js")
> 
> (defun moz-get-prefs (key)
>   "Returns value in prefs.js corresponding to key. key is line in prefs.js
> file, up to desired value (which is followed by closing double quote).
> Returns nil, if no key or value not found. Requires the variable
> moz-prefs-filename, which is set in e-config.el."
> 
>   (with-temp-buffer
>     (condition-case err
>     (insert-file-contents-literally moz-prefs-filename)
>       (error 'nil))
>     (if (re-search-forward key nil t)
>     (setq server (match-string 1))
>       'nil)))
> 
> And here is how I call it:
> 
>   (moz-get-prefs
>        "user_pref(\"mail.server.server1.hostname\", \"\\([^\"]+\\)")


That's rather awkward Emacs Lisp style.  I would write it as:

(defvar moz-user-pref-file "~/.mozilla/...[random name].../default/prefs.js")

(defun moz-user-pref (key)
   "Return the user_pref value for KEY in the `moz-user-pref-file' file."
   (let ((key-regexp (format "user_pref(\"%s\", \"\\([^\"]+\\)\")" key)))
     (with-temp-buffer
      (condition-case nil
	 (insert-file-contents-literally moz-user-pref-file)
        (error nil))
      (if (re-search-forward key-regexp nil t)
	 (match-string 1)))))

(setq server
       (moz-user-pref "mail.server.server1.hostname"))

> Unfortunately, it gets a little more tricky, as I should check that
> mail.server.server*.type
> is pop3 or imap, and not nntp, but this is good enough.

Is that information in the prefs.js file, or do you have to querey the server?


-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

  reply	other threads:[~2003-04-22 16:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-17 16:20 extract regexp Bruce Ingalls
2003-04-17 17:11 ` lawrence mitchell
2003-04-17 17:31   ` Kevin Rodgers
2003-04-22 14:08     ` Bruce Ingalls
2003-04-22 16:28       ` Kevin Rodgers [this message]
2003-04-22 17:31         ` Bruce Ingalls

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=3EA56DB8.3090909@yahoo.com \
    --to=ihs_4664@yahoo.com \
    /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).