Top / EmacsChangelog

はじめに

英語のMLをメモしたもの.

何かあれば適当に追加してください.

日本語の ML をメモしたものは MLMemo にあります.

emacs-devel

平成17年3月19日(土)

Message をファイルに保存

From: Brad Collins
Subject: How to automatically write *Messages" buffer to a file?
Date: Wed, 24 Nov 2004 12:43:37 +0900

Is there is a simple way of getting Emacs to automatically append
messages in the message buffer to a file so messages work as a log file?

I've been looking around and it seems this should be dead easy but I
can't figure it out?

b/
From: Joe Corneli
Subject: Re: How to automatically write *Messages" buffer to a file?
Date: Thu, 25 Nov 2004 13:56:20 +0900

OK, so I tried rewriting the code without advice.

But there are still a number of problems.

First of all, it seems that the arguments being sent to the
`after-change-functions' aren't quite right.  

There may be other problems too.

;; messages to log file

(defun start-logging ()
  (interactive)
  (set-buffer "*Messages*")
  (add-hook 'after-change-functions 'write-to-log)
  (message (concat "begin logging " (current-time-string))))

(defun write-to-log (beg end len) 
  ;; This message reveals that the *Messages* buffer
  ;; and the echo area are joined at the hip.  `beg'
  ;; and `end' are positions in the echo area!
; (message (format "%s %s" (- (point-max) (- end beg)) (point-max)))
  (save-excursion (set-buffer "*Messages*")
                  (write-region 
                   ;; this region doesn't seem to include the
                   ;; final character, but I can't change the
                   ;; way it is written or I get error.
                   ;;
                   ;; the obvious choice 
                   ;;   beg end
                   ;; doesn't work either.
                   (- (point-max) 
                      (- end beg))
                   (point-max)
                   "~/LOG" t 'quiet)))

(defun stop-logging ()
  (interactive)
  (message (concat "stop logging " (current-time-string)))
  (set-buffer "*Messages*")
  (remove-hook 'after-change-functions 'write-to-log))

(defun test-message ()
  (interactive)
  (message "hi"))
From: Kevin Rodgers
Subject: Re: How to automatically write *Messages" buffer to a file?
Date: Thu, 02 Dec 2004 04:08:42 +0900

Brad Collins wrote:
 > Is there is a simple way of getting Emacs to automatically append
 > messages in the message buffer to a file so messages work as a log file?

This should get you most of the way there (when you exit emacs, it
should ask you whether you want to save that log file):

(with-current-buffer "*Messages*"
   (set buffer-file-name "~/*Messages*")) ; or set-visited-file-name

-- 
Kevin Rodgers

dired でマークしたファイルにコマンド実行

dired でマークしたファイルにマークした順番にコマンドを実行する話

From: Stephen Dickey
Subject: dired question
Date: Mon, 18 Oct 2004 08:20:59 +0900

I would like to run a command on files marked in a dired buffer in the
order in which they were marked.  Is there a built in way to do this?
If not, I was thinking of advising dired-mark and
dired-get-marked-files to do this.  Does this approach seem
reasonable?

返信

From: Stephen Dickey
Subject: Re: dired question
Date: Tue, 19 Oct 2004 03:05:40 +0900

Stefan Monnier writes:

> > I would like to run a command on files marked in a dired buffer in the
> > order in which they were marked.  Is there a built in way to do this?
> 
> Dired does not keep track of the order in which things were marked.
> It just keeps a bit saying "marked/not-marked".
> 
> > If not, I was thinking of advising dired-mark and
> > dired-get-marked-files to do this.  Does this approach seem reasonable?
> 
> I'm not very familiar with dired's internals, so don't take my word for it,
> but it does seem like a reasonable way.  E.g. just maintain in dired-mark
> a side list of the last N files marked (N being e.g. the number of lines in
> the current buffer) and use it in dired-get-marked-files to sort the
> marked files.

OK, thanks.

It was simpler than I thought to quickley cobble something together to
do what I want. This is what I ended up with:

(require 'dired)
(require 'cl)

(make-variable-buffer-local 'srd-mark-list)

(defadvice dired-mark (before srd-dired-mark)
  (if (equal dired-marker-char ?\040)
      (setq srd-mark-list
            (remove (dired-get-filename) srd-mark-list))
      (setq srd-mark-list
            (adjoin (dired-get-filename)
                    srd-mark-list
                    :test #'equal))))

(ad-activate 'dired-mark)

(defun srd-do-shell-command (command)
  (interactive "scommand: ")
  (dired-do-shell-command command
                          nil
                          (reverse srd-mark-list)))

いろいろ問題はありそうで

>       (setq srd-mark-list
>             (adjoin (dired-get-filename)
>                     srd-mark-list
>                     :test #'equal))))

Aka (add-to-list 'srd-mark-list (dired-get-filename))

とか

I suspect this will break in cases where you do:
- mark A, B, C
- C-k on B
- !

because B will not be among the marked files any more but will still be in
srd-mark-list.

isearch

From: Juri Linkov
Subject: Type Ahead Find
Date: Sat, 19 Mar 2005 04:45:29 +0900

Many modern applications provide a feature called "type-ahead find".
In fact, this is rather a poor imitation of Emacs incremental search
with many limitations.  But it allows to narrow the search only
to specific text part (such as e.g. in Firefox typing a ' before the
search string searches only links) which is currently not easily
implementable in Emacs.  However, a simple 4-line change in isearch.el
will allow this.  The idea is to add a new variable to hold a predicate
function which, when called on the new search position, will return nil
when the current search point should be skipped.  Such a function,
when defined, will be used instead of the default `isearch-range-invisible'
to allow searching even in hidden parts.

One of possible uses of such a variable is to search only references,
menu items, indexes and links in Info manuals with simple code like this:

(set (make-local-variable 'isearch-success-function)
     (lambda () (save-match-data
	 (setq isearch-error
	       (or (Info-get-token (point)
		    "[hf]t?tp://" "[hf]t?tp://\\([^ \t\n\"`({<>})']+\\)")
		   (Info-get-token (point)
		    "\\*note[ \n\t]+"
		    "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?")
		   (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::")
		   (Info-get-token (point) "\\* +" "\\* +\\(.*\\): "))))))

It displays the name of the current objects under point in square
brackets, so e.g. `C-s gnu' in the top node of the Emacs manual produces:

I-search: gnu [GNU Free Documentation License]

where `GNU Free Documentation License' is the menu item and node name
under the search point.

This change will also allow to implement links-only search in the
Emacs w3m browser with the following simple code:

(set (make-local-variable 'isearch-success-function)
     (lambda () (save-match-data (setq isearch-error (w3m-anchor)))))

which will display a link under the search point in square brackets:

I-search: gnu [http://www.gnu.org/]

This change has many other possible uses like for example searching
only in comments with:

(set (make-local-variable 'isearch-success-function)
     (lambda () (save-match-data (save-excursion (comment-beginning)))))

All this can be done with a new variable `isearch-success-function'.
In contrast with `isearch-search-fun-function' which mainly is used to
widen the search space (e.g. to other Info nodes, etc.), the new
variable `isearch-success-function' narrows the standard search space
to specific buffer regions.  It removes the need to write a complicated
search function for `isearch-search-fun-function'.

The patch below also fixes lazy highlighting to support
`isearch-success-function' with changing `isearch-lazy-highlight-search'
to look more like `isearch-search', i.e. to add a similar retry-success
while-loop, which also with using of `isearch-range-invisible' (when
`isearch-success-function' is nil) reduces the amount of created overlays
that currently are created in the hidden text.

The test for `(not isearch-error)' was removed from
`isearch-lazy-highlight-new-loop' to allow displaying the names
in square brackets (`isearch-lazy-highlight-search' takes care
about incomplete regexps).

There is also a similar change in info.el.

The actual code that would use this new variable and user interface
for its activating is a separate question.

Index: lisp/isearch.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v
retrieving revision 1.261
diff -u -w -b -r1.261 isearch.el
--- lisp/isearch.el	18 Mar 2005 09:59:31 -0000	1.261
+++ lisp/isearch.el	18 Mar 2005 19:32:34 -0000
@@ -165,6 +165,9 @@
   "Function to save a function restoring the mode-specific isearch state
 to the search status stack.")
 
+(defvar isearch-success-function nil
+  "Function to report whether the new search match is considered successful.")
+
 ;; Search ring.
 
 (defvar search-ring nil
@@ -2056,8 +2059,10 @@
 		  (not isearch-success)
 		  (bobp) (eobp)
 		  (= (match-beginning 0) (match-end 0))
+		  (if isearch-success-function
+		      (funcall isearch-success-function)
 		  (not (isearch-range-invisible
-			(match-beginning 0) (match-end 0))))
+			  (match-beginning 0) (match-end 0)))))
 	      (setq retry nil)))
 	(setq isearch-just-started nil)
 	(if isearch-success
@@ -2369,7 +2374,6 @@
                          isearch-lazy-highlight-window-end))))
     ;; something important did indeed change
     (lazy-highlight-cleanup t) ;kill old loop & remove overlays
-    (when (not isearch-error)
       (setq isearch-lazy-highlight-start-limit beg
 	    isearch-lazy-highlight-end-limit end)
       (setq isearch-lazy-highlight-window       (selected-window)
@@ -2384,7 +2388,7 @@
       (unless (equal isearch-string "")
 	(setq isearch-lazy-highlight-timer
 	      (run-with-idle-timer lazy-highlight-initial-delay nil
-				   'isearch-lazy-highlight-update))))))
+				 'isearch-lazy-highlight-update)))))
 
 (defun isearch-lazy-highlight-search ()
   "Search ahead for the next or previous match, for lazy highlighting.
@@ -2393,6 +2397,10 @@
 	(isearch-regexp isearch-lazy-highlight-regexp)
 	(search-spaces-regexp search-whitespace-regexp))
     (condition-case nil
+	(let ((retry t)
+	      (success nil))
+	  (while retry
+	    (setq success
 	(funcall (isearch-search-fun)
 		 isearch-lazy-highlight-last-string
 		 (if isearch-forward
@@ -2404,7 +2412,14 @@
 			(if isearch-lazy-highlight-wrapped
 			    isearch-lazy-highlight-end
 			  (window-start))))
-		 t)
+			   t))
+	    (if (or (not success)
+		    (if isearch-success-function
+			(funcall isearch-success-function)
+		      (not (isearch-range-invisible
+			    (match-beginning 0) (match-end 0)))))
+		(setq retry nil)))
+	  success)
       (error nil))))
 
 (defun isearch-lazy-highlight-update ()

Index: lisp/info.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/info.el,v
retrieving revision 1.421
diff -u -r1.421 info.el
--- lisp/info.el	16 Mar 2005 07:32:43 -0000	1.421
+++ lisp/info.el	18 Mar 2005 19:33:20 -0000
@@ -1505,9 +1505,11 @@
 	  (while (and (not give-up)
 		      (save-match-data
 			(or (null found)
-			    (if backward
-				(isearch-range-invisible found beg-found)
-			      (isearch-range-invisible beg-found found))
+			    (if isearch-success-function
+				(not (funcall isearch-success-function))
+			      (if backward
+				  (isearch-range-invisible found beg-found)
+				(isearch-range-invisible beg-found found)))
 			    ;; Skip node header line
 			    (and (save-excursion (forward-line -1)
 						 (looking-at "\^_"))
@@ -1593,9 +1595,11 @@
 		(while (and (not give-up)
 			    (save-match-data
 			      (or (null found)
-				  (if backward
-				      (isearch-range-invisible found beg-found)
-				    (isearch-range-invisible beg-found found))
+				  (if isearch-success-function
+				      (not (funcall isearch-success-function))
+				    (if backward
+					(isearch-range-invisible found beg-found)
+				      (isearch-range-invisible beg-found found)))
 				  ;; Skip node header line
 				  (and (save-excursion (forward-line -1)
 						       (looking-at "\^_"))

-- 
Juri Linkov
http://www.jurta.org/emacs/

popup-toolbar

http://thread.gmane.org/gmane.emacs.sources/997

通常はツールバーを隠しておいて,メニューを押すとツールバーが現れるというもの.で, バッファを選択すると,ツールバーはまた消える.

dired-aux

「dired-kill-tree」。あるディレクトリ下にあるサブディレクトリのdired バッファを一括削除する

置換

「improving query-replace and query-replace-regexp」

M-% RET で前回の置換を実行ができると便利では?という話.

レジスタ

「Using overlay in register」(Masatake YAMATO)と menu interface for registers (Masatake YAMATO).

メニューからレジスタにアクセスできるパッチ.ストールマンはメニューからじゃ遅いか ら,使い勝手が悪いんじゃないのとか言われてるけど,レジスタというものを知るにはい いかな.

dired

dired-do-touch (Matthew Mundell).dired で T により,touch を実行するもの.弱っ たなぁ...設定済みMeadowでは T を文字コードの変換に割り当てているんだよなぁ...

補完バッファ

「Emphasize the character to be typed next in *Completions*」(Masatake YAMATO).

以下本文.これは欲しいな.ちなみにこんな感じ。

#ref(): The style ref(filename,pagename) is ambiguous and become obsolete. Please try ref(pagename/filname)

This patch improves visual feedback of *Completions* buffer. So 
the user can know the character to be typed next in mini buffer
more easily.

Consider you type "C-x C-f ChangeLog. tab tab" at emacs/lisp directory.
The minibuffer looks like:

    Find file: ~/hack/emacs/lisp/ChangeLog

and *Completions* buffer looks like:

    Click <mouse-2> on a completion to select it.
    In this buffer, type RET to select the completion near point.

    Possible completions are:
    ChangeLog.1                    ChangeLog.10
    ChangeLog.2                    ChangeLog.3
    ChangeLog.4                    ChangeLog.5
    ChangeLog.6                    ChangeLog.7
    ChangeLog.8                    ChangeLog.9

You will look into *Completions* buffer to find the file
name which you want to load into emacs.

My patch make the first different character in all completions
bold. In above example, characters marked by ^ is made bold.

    ChangeLog.1                    ChangeLog.10
              ^                              ^
    ChangeLog.2                    ChangeLog.3
              ^                              ^
    ChangeLog.4                    ChangeLog.5
              ^                              ^
    ChangeLog.6                    ChangeLog.7
              ^                              ^
    ChangeLog.8                    ChangeLog.9
              ^                              ^
So the user can know which key should be typed to choose
a completion easily.

パッケージ

「Including URL library in Emacs」(Stefan Monnier).

I think the time has come: any objection to my asking savannah people to
move the RCS files under the url/lisp directory (in URL's repository) into
emacs/lisp/url (in Emacs's repository) ?

なんだそうな.

Tree-Widget

http://emhacks.sourceforge.net/tw-shots.html

こんなのもあるのか.

関数の詳細を表示

「Improved help from minibuffer prompts」(Stefan Reichor).C-xC-f F1 などをお試 しあれ.

(defun xtla-display-command-help (command &optional current-prompt)
  (save-excursion
    (other-window -1)
    (let ((cmd-help (when (fboundp command) 
                      (documentation command))))
      (with-current-buffer (get-buffer-create "*xtla-command-help*")
        (delete-region (point-min) (point-max))
        (insert (if cmd-help
                    (format "Help for %S:\n%s" command cmd-help)
                  (format "No help available for %S" command)))))
    (display-buffer "*xtla-command-help*")
    (resize-temp-buffer-window)
    (other-window 1)))
 
(define-key minibuffer-local-map [f1] 'xtla-show-command-help)
(define-key minibuffer-local-completion-map [f1] 'xtla-show-command-help)
(define-key minibuffer-local-must-match-map [f1] 'xtla-show-command-help)
 
(defvar xtla-command-stack nil)
(defun xtla-minibuffer-setup ()
  (push  this-command xtla-command-stack))
(add-hook 'minibuffer-setup-hook 'xtla-minibuffer-setup)
 
(defun xtla-minibuffer-exit ()
  (pop xtla-command-stack))
(add-hook 'minibuffer-exit-hook 'xtla-minibuffer-exit)
 
(defun xtla-show-command-help ()
  (interactive)
  (xtla-display-command-help (car xtla-command-stack) 
                             (minibuffer-prompt)))

help.gnu.emacs

平成17年3月19日(土)

scratch の保存

From: Frederic Motte
Subject: (kill-buffer "*scratch*")
Date: Thu, 23 Sep 2004 21:59:07 +0900

I hate Emacs' scratch buffer !!!

The other night, I was not able to sleep, thinking about a game world.
So I jumped out of my bed to write it down. Once I was happy of my
work, I went back in bed feeling good.

Today, I wanted to read it again, but impossible to found it back.
I think I wrote it in the scratch buffer and closed emacs without
saving it.
Of course, emacs didn't asked me if I would like to save it.

I hate Emacs' scratch buffer.

By the way, I didn't mention that I love emacs, thanks a lot.
From: Kevin Rodgers
Subject: Re: (kill-buffer "*scratch*")
Date: Fri, 24 Sep 2004 00:38:11 +0900

Frederic Motte wrote:
 > The other night, I was not able to sleep, thinking about a game world.
 > So I jumped out of my bed to write it down. Once I was happy of my
 > work, I went back in bed feeling good.
 >
 > Today, I wanted to read it again, but impossible to found it back.
 > I think I wrote it in the scratch buffer and closed emacs without
 > saving it.
 > Of course, emacs didn't asked me if I would like to save it.

But it did tell you:

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

Try adding this to your .emacs file:

(save-excursion
   (set-buffer "*scratch*")
   (setq buffer-offer-save t))

-- 
Kevin Rodgers

occur

「M-x occur and stepping through matches」 (Ted Zlatanov).

The latest Emacs in CVS now directly allows next-error to interface
with occur-mode (my patch made it in).  So you can use C-x ` (the
default binding for next-error) and it will go to the next
occurence.  I hope that helps.

occur が compile で扱えるのか.

help-emacs-windows

平成17年3月25日(金)

dired

From: "Andreas Wieweg"
Subject: Re: Re: Global search/replace across files?
Newsgroups: gmane.emacs.windows
Date: Sat, 22 Jun 2002 02:08:30 +0900
Message-ID: <032201c21946$45537e20$14930ac1@manticora>

> 
> > Incidentally, why isn't there something like a
> > dired-find-marked-files command? And if "Most commands operate on
> > the marked files..." why doesn't "f" (dired-find-file)? Can't I even
> > visit the marked files? 
> 

Here is one posible solution found from google:

(defun dired-do-flagged-find ()
  "In dired, find the files flagged for loading.   
\\[dired-do-flagged-find]"
  (interactive)
  (let* ((dired-marker-char dired-marker-char)
  (regexp (dired-marker-regexp))
  case-fold-search)
    (save-excursion 
      (goto-char (point-min))
      (while (re-search-forward regexp nil t)
        (save-excursion
          (message "Opened file: %s" 
                   (find-file (dired-get-filename))))
        )
      )))
 (define-key dired-mode-map "F" 'dired-do-flagged-find)
 (define-key dired-mode-map [menu-bar operate find-flagged]
   '("Find Marked Files" . dired-do-flagged-find))

/ Andreas Wieweg

dired2

From: Jean-Philippe Theberge
Subject: Dired on windows
Newsgroups: gmane.emacs.windows
Date: Thu, 06 Feb 2003 23:09:41 +0900
Message-ID: <uu1fhwlei.fsf@cesart.net>

Hi,

Is there a mode for dired to browse down to top level?

Supposed I in the directory C:/ and I hit the '..' entry, I would like
to got to a dired buffer that will show me available drives (a:/, c:/,
d:/ e.t.c) (like in "my computer")

Thanks!

-jp

From: Jean-Philippe Theberge
Subject: Re: Re: Dired on windows
Newsgroups: gmane.emacs.windows
Date: Thu, 13 Feb 2003 02:27:13 +0900
Message-ID: <ur8adflzi.fsf@cesart.net>

Thanks you all for the hints.

Here's my first draft...
(only show the network drives)

(defun netdir()
  (interactive)
  (require 'widget)
  (let ((drvL))
    (with-temp-buffer
      (shell-command "net use" (current-buffer))
      (while (re-search-forward "[A-Z]: +\\\\\\\\[^ ]+" nil t nil)
	(setq drvL (cons (split-string (match-string 0)) drvL))))
    (pop-to-buffer "*NET DIR LIST*")
    (erase-buffer)
    (widget-minor-mode 1)
    (mapcar
     (lambda (x)
       (lexical-let ((x x))
	 (widget-create 'push-button
			:notify (lambda (widget &rest ignore)
				  (kill-buffer (current-buffer))
				  (dired (car x)))
			(concat (car x) "  " (cadr x))))
       (widget-insert "\n"))
     drvL)))

-jp

From: jeff.rancier@softechnics.com
Subject: Re: Dired on windows
Newsgroups: gmane.emacs.windows
Date: Tue, 11 Feb 2003 06:07:06 +0900
Message-ID: <u3cmvonet.fsf@softechnics.com>

>>>>> "Francis" == Francis J Wright <> writes:
    >> 
    >> (defun show-net-connections ()
    >> (interactive)
    >> (shell-command "net use"))


    > I thought that was available only on Win NT and not 9x.  Also, I can't find
    > an analogous way to display local drives.

It seems to work fine on XP Pro, 98, 95 fine, (although there's an extra heading
on XP Pro (Network) and the name of the heading a slightly
different).  Nothing Sed and Awk couldn't grok.

-- 

Thanks,
Jeff
,----
| Jeffery B. Rancier
| 
| Softechnics
| a METTLER TOLEDO company
`----

compile

From: Ben Key
Subject: Help with defadvice
Newsgroups: gmane.emacs.windows
Date: Wed, 18 Jun 2003 22:41:36 +0900
Message-ID: <762A7BB74D6AD51195EF00B0D0AA16602C39A9@STPETE>

I am trying to  modify Emacs to use a more intelligent method of setting the
value of compile command.

I have defined a function that calculates the compile command and I am
trying to get compile to call the function prior to displaying the
compile-command prompt using defadvice.  For some reason it is not working.
What am I doing wrong?

(defun bk-set-compile-command ()
 "Attempts to sets compile-command so that the project contained in the
directory
associated with the current buffer may be built successfully."
 (interactive)
 (message "bk-set-compile-command")
 (if (memq system-type '(windows-nt))
   (progn
    (make-variable-buffer-local 'bk-current-compile-command)
    (make-variable-buffer-local 'compile-command)
    (let (
       (dsw-file nil)
       (dsp-file nil)
       (project-name nil)
       (msvc-make-file nil)
       )
     (setq dsw-file
        (or
         (car-safe
         (directory-files
          (file-name-directory (buffer-file-name))
          t
          "\\.dsw$"))
         (car-safe
         (directory-files
          (expand-file-name (concat (file-name-directory (buffer-file-name))
"../"))
          t
          "\\.dsw$"))
         )
        )
     (setq dsp-file
        (car-safe
         (directory-files
         (file-name-directory (buffer-file-name))
         t
         "\\.dsp$"))
        )
     (setq msvc-make-file
        (car-safe
         (directory-files
         (file-name-directory (buffer-file-name))
         t
         "MSVCMakeFile"))
        )
     (if (not msvc-make-file)
       (setq msvc-make-file
          (car-safe
           (directory-files
           (file-name-directory (buffer-file-name))
           t
           "makefile.msvc"))
          )
      )
     (if (and dsw-file dsp-file)
       (progn
        (setq project-name (file-name-sans-extension (file-name-nondirectory
dsp-file)))
        (setq compile-command
           (format "msdev %s /MAKE \"%s - Win32 \"" dsw-file project-name))
        (setq msdev-current-compile-command compile-command)
        (message "compile-command is now '%s'" compile-command)
        )
      (if msvc-make-file
        (progn
         (setq compile-command
            (format "nmake -f %s" msvc-make-file))
         (setq msdev-current-compile-command compile-command)
         (message "compile-command is now '%s'" compile-command)
         )
       )
      )
     )
    )
  )
 )

(if (fboundp 'defadvice)
  (progn
   (defadvice compile (before bk-set-compile-command-advice activate)
    (bk-set-compile-command)
    )
   (ad-enable-advice 'compile 'before 'bk-set-compile-command-advice)
   (ad-activate 'compile)
   )
 )

From: Sunil S. Patel
Subject: Re: Help with defadvice
Newsgroups: gmane.emacs.windows
Date: Wed, 18 Jun 2003 23:16:53 +0900
Message-ID: <16112.29781.890000.34126@pcdoh.wpc.frco.com>

Try my snippet below...it does something similiar to what you want..

I am by far, an idiot with elisp....and after much struggle I came up with
this below, which work pretty well for me...for VC++ 6.0...issue the M-x
compile, once and the compile line is made, and then you can hit F7 to
recompile just like you do in DevStudio....only drawback with what I have
below, is that you must be visiting a file in the directory, or it doesn't
work...like have a dired of the files is not good enough....I wish I knew
enough to fix that....


; Set up for Visual C++ compiling
(define-key global-map [f7] 'recompile)
(define-key global-map [C-cancel] 'kill-compilation)

(defun my-compile()
  "Sets up 'compile-command' to the VC++ .dsp in the current directory"
  (interactive)
  (make-variable-buffer-local 'compile-command)
  ; look for the first .dsp file we find
  (setq proj-dsp (car (directory-files "./" nil "\\.dsp$")))
  ; strip off .dsp extension
  (if (equal proj-dsp nil)
      (setq proj-dsp "PROJ.dsp"))
  ;(message "project name is '%s'" proj-dsp)
  (setq proj-name (file-name-sans-extension proj-dsp))
  (setq compile-command
        (format "MSDEV %s /MAKE \"%s - Win32 Debug\"" proj-dsp proj-name))
)
(add-hook 'c++-mode-hook   'my-compile)

From: "Richard M. Heiberger"
Subject: RE: Help with defadvice
Newsgroups: gmane.emacs.windows
Date: Thu, 19 Jun 2003 07:48:43 +0900
Message-ID: <200306182248.SAA25349@fisher.stat.temple.edu>

It looks like w32-shell-execute might do what you want.
It uses the file extension associations that windows uses, and you
can add your extensions in by clicking thorugh windoes explorer.

I use C-c C-f in the dired to get the windows standard behavior.
I also have some specific extensions that I use, for example
.  myfile.eps.gz  goes to ghostview, not wherever windows would send .gz files.
I constructed this based on discussion on this list:

-------------- exec.el
(require 'dired)

(defun execute-dired-find-file ()
  "In dired, run the w32-shell-execute on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil (dos-canonical-name (dired-get-filename))))
(define-key dired-mode-map "\C-c\C-f" 'execute-dired-find-file)

(defun word-dired-find-file ()
  "In dired, run the MS Word on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "winword" (w32-short-file-name (dired-get-filename))))
(define-key dired-mode-map "\C-c\C-w" 'word-dired-find-file)

(defun excel-dired-find-file ()
  "In dired, run the MS Excel on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "c:/progra~1/micros~2/office10/excel.exe"
		     (w32-short-file-name (dired-get-filename))))
(define-key dired-mode-map "\C-cx" 'excel-dired-find-file)

(defun wordpad-dired-find-file ()
  "In dired, run the MS wordpad on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "wordpad" (w32-short-file-name (dired-get-filename))))
(define-key dired-mode-map "\C-c\C-p" 'wordpad-dired-find-file)

(defun explorer-dired-find-file ()
  "In dired, run the MS Windows Explorer on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "explorer" (concat "/e,"
  (dos-canonical-name
  (file-name-directory (w32-short-file-name (dired-get-filename)))))))
(define-key dired-mode-map "\C-c\C-e" 'explorer-dired-find-file)

(defun dos-canonical-name (filename)
"Canonicalize filename forcing `\\' as directory-sep-char."
  (let ((directory-sep-char ?\ ))
    (expand-file-name filename)))

(defun gsview-dired-find-file ()
  "In dired, run Ghostview on this file."
  (interactive)
  ;; dired-get-filename is defined in dired.el
  (w32-shell-execute nil "gsview32" (dired-get-filename)))
(define-key dired-mode-map "\C-c\C-g" 'gsview-dired-find-file)

----------------------- end exec.el
Rich

From: Jeff Paquette
Subject: RE: Help with defadvice
Newsgroups: gmane.emacs.windows
Date: Fri, 20 Jun 2003 01:15:23 +0900
Message-ID: <33C532BE91E4C34F99E23E74E49E83F72842F2@exchange.nugenesis.com>

Another way, if you have perl installed, is to use the following:

(defun jdp-msdev-build-active-project ()
  (interactive)
  (save-some-buffers)
  (let ((val (run-perl "require Win32::OLE;"
		       "my $app =
Win32::OLE->GetActiveObject('MSDev.Application');"
		       "$app = Win32::OLE->new('MSDev.Application') if !
defined $app;"
		       "exit 1 if ! defined $app;"
		       ;; State 1 is Maximized, 2 is minimized, 3 is normal
		       "$app->{'WindowState'} = 1 if $app->{'WindowState'}
== 2;"
		       "$app->{'Visible'}=1;"
		       "$app->{'Active'}=1;"
		       "$app->ExecuteCommand( \"Build\" );"
		       "exit 0;"
		       )))
    (cond ((= val 1)
	   (error "MSDev not running"))
	  (t
	   (error "Failed to connect to MSDev")))))


This will build the active project in an already-running MSDev.
From: Jeff Paquette
Subject: RE: Help with defadvice
Newsgroups: gmane.emacs.windows
Date: Fri, 20 Jun 2003 01:59:05 +0900
Message-ID: <33C532BE91E4C34F99E23E74E49E83F72842F3@exchange.nugenesis.com>

Whoops, it's

(defun run-perl (&rest stmts)
  (call-process "perl" nil nil nil "-e" (apply 'concat stmts)))

From: "Gallucci, David"
Subject: RE: Help with defadvice
Newsgroups: gmane.emacs.windows
Date: Fri, 20 Jun 2003 02:02:01 +0900
Message-ID: <C6317ED2939D684C9FBE85D574CC5E62393824@mer-exch1.corp.nasdaq.com>

Here's something we use. It is a batch for the .Net version ( 7.1 actually
). Not a makefile, but then again you don't have to regen makefiles either. You
can do a setq compile-command like so:

(setq compile-command "d:/myprojects/solutions/buildsolution.bat") 

You can modify to suit your needs. 

Hope this helps,

Dave Gallucci

---------------------

ECHO OFF

REM Get name of solution from current directory. There should be only one!
FOR /f "DELIMS==" %%a in ('DIR /b/a *.sln') DO SET ROOTNAME=%%~na

REM Derive variables based on root name
SET BUILDLOG=%ROOTNAME%.log
SET SOLUTION=%ROOTNAME%.sln
DEL %BUILDLOG%

CLS
ECHO.
ECHO.***************************************************************************
ECHO.
ECHO        Building Project(s) Based on %SOLUTION% Solution File.
ECHO        Results will be written to %BUILDLOG%
ECHO.
ECHO.***************************************************************************

CALL "%VS71COMNTOOLS%vsvars32.bat" >nul
ECHO OFF
ECHO.
ECHO        Build in progress. Please wait...
ECHO.
ECHO.
devenv %SOLUTION% /rebuild "Release" /out %BUILDLOG%
CLS
ECHO.
ECHO        Build complete. See %BUILDLOG% for results.
ECHO.
ECHO.
PAUSE

---------------------

ファイルのリスト

From: Tom Capey
Subject: Re: Display list of types of files in a directory
Newsgroups: gmane.emacs.windows
Cc: help-emacs-windows@gnu.org
Date: Thu, 18 Mar 2004 20:31:25 +0900
Message-ID: <u1xnqs86q.fsf@edina.co.uk>

* rob.davenport <> writes:

> Years ago I used to use a command-line utility on Windows called
> PocketD which would (with the correct parameters used) display
> a list of the types of files (based on extension) in a directory, and
> the number and percentage of each.

> For example,  a typical output might have looked like:

> Directory of d:\projects\code\test1
> Ext
> -----
> h       ****************** (34) 31%
> cpp     ************** (28)             21%
> obj     ************** (28)             21%
> sbr     ************** (28)             21%
> pdb        * (1)                          1%
> ....
> etc.

> That's not exact (and I doubt the numbers add up), but that's the
> general
> idea.
> There were other options to show size allocated to each type etc.

  here's a start:

(require 'cl)

(defun pocket-d-display-directory (directory)
  (interactive "DDirectory: ")
  (let ((suffix-count '())
        (total 0)
        (max 0)
        (target-column 50)
        (buffer (get-buffer-create "*Pocket D Display*"))
        (extension-description "Extension:"))
    (set-buffer buffer)
    (erase-buffer)
    (loop for file in (remove-if-not #'file-regular-p (directory-files directory t))
          for suffix = (file-name-extension file)
          for assoc-elt = (assoc suffix suffix-count)
          count file into suffix-total
          maximize (length suffix) into max-length
          finally (setq total suffix-total
                        max (max (length extension-description)
                                 max-length))
          if assoc-elt
          do (incf (cdr assoc-elt))
          else
          do (push (cons suffix 1) suffix-count))

    (insert "Directory of " directory "\n\n"
            extension-description "\n"
            (make-string (length extension-description) ?=)
            "\n\n"
            "")
  
    (if (zerop total) (insert "No files found")
      (loop for elt in (sort* suffix-count #'string< :key #'car)
            do (insert (format "%s" (car elt)))
               (insert (make-string (1+ (- max (current-column))) ? ))
               (insert (make-string (- target-column (current-column)) ?*))
               (insert (format "  %2d (%.2f%%)\n"
                               (cdr elt)
                               (* 100 (/ (cdr elt) (float total)))))))
    (switch-to-buffer-other-window buffer)))



/Tom

添付ファイル: filecomp.png 1118件 [詳細]

リロード   新規 編集 凍結 差分 添付 複製 改名   トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS
Last-modified: Fri, 28 Dec 2007 17:21:42 JST (3559d)