help-emacs-windows
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [h-e-w] gnuclientw is starting new instances of emacs.


From: Galen Boyer
Subject: Re: [h-e-w] gnuclientw is starting new instances of emacs.
Date: 15 Nov 2001 14:06:16 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

On Thu, 15 Nov 2001, address@hidden wrote:
> Thanks to Richard, Jeff, and Andy.
>> (defadvice server-find-file
>>   (before server-select-current-frame activate)
>>   "Select current frame before gnuserv finds a file"
>>   (setq gnuserv-frame (selected-frame)))
> 
> This works great! I can't wait to learn Lisp so that I can know
> exactly what it's doing.

The people that helped you with your code are probably much more
sophisticated in their view of elisp, but here is mine.  (There
is an elisp debugger and some really sophisticated terminology
and thought process to be good at it, of which I am not even
close as well as lots of great code to read and use as examples.)

My simplified view for understanding elisp is that it is sort of
like mathematics.  Start at the inner parentheses and work your
way out (Make sure you have turned on parentheses matching and
also to understand how to jump in and out of nested functions).
At any closing parentheses, do C-x C-e and you can find out what
that section is doing.  I'm not a big elisp coder, but I find it
fairly logical to read, once you get used to the math/parentheses
thingy.  To read, I use C-h f and C-h v, find-function and
find-library all the time, as well as speedbar.  For coding, I
use C-h k to find the function I need to call (ie, I usually know
how to do what I need at this section with the keyboard), then
C-h f on that function to see how I need to call it (or even more
important, should I call it within elisp functions at all) and
then I start stringing function calls together to make some
makeshift, horribly written but functional elisp code for myself.
(I basically am building keyboard macros into elisp code this
way.)

Here's a perfect example of one I wrote the first month or two
using Emacs, and still, to this day, the most useful function I
have ever coded (considering the number of times I call it)

(defun favorites-write-url (url-name)
  (interactive "sName For Favorite File: ")
  (save-excursion
    (switch-to-buffer url-name)
    (insert "[DEFAULT]\nBASEURL=")
    (yank)
    (insert "\n[InternetShortcut]\nURL=")
    (yank)
    (insert "\nModified=C0649490B1E9BE01A1")
    (setq favorites-dir
          (concat  "c:/Documents And Settings/" (user-login-name) 
"/favorites/"))
    ;; Need to make this work on all versions of windows.
                                        ;     (setq favorites-dir
                                        ;         (concat (getenv "WINDIR") 
"/profiles/" (user-login-name) "/favorites/"))
    (write-file (concat favorites-dir url-name ".url"))
    (kill-buffer (concat url-name ".url"))
    (dired favorites-dir)
    (beginning-of-buffer)
    (revert-buffer)
    (nonincremental-search-forward url-name)))

This builds a file that is stored in the favorites directory for
Internet Explorer (although, it only works on W2K because of the
hardcoded way of getting the favorites directory, the commented
part worked for NT, I believe).  It assumes that you have a url
copied from windows (ie, Alt-D Ctrl-C when browsing with IE and
Alt-Tab to Emacs for capturing the copied url to the favorites).
It then asks you for a name, which the favorites file will be
called (it appends the .url extension to that name).  It then
builds the file, saves it to the favorites folder and then opens
a dired buffer with point on the newly created file.  You then
use dired commands to organize the favorites folder.  I have used
this code for over two years and have compiled quite an extensive
favorites collection, that is also well organized.  I haven't had
to Favorites --> Organize Favorites since.  I hated how slow IE
was in bringing up the Organize Favorites interface and how it
named things with _really_ long names for me.  I also hated that
there is no completion as I move and rename files.  I also have
the favorites folder bookmarked, so I can jump to the favorites
folder for quick maintenance.  (Emacs helps make windows more
Emacs like in many ways.  I use Emacs to organize my windows
start button as well with basically the same gripes and, man, is
that a godsend.)

Oh well, sorry if I have butchered elisp or its descriptions.

-- 
Galen deForest Boyer
Sweet dreams and flying machines in pieces on the ground.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]