emacs-devel
[Top][All Lists]
Advanced

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

Byte compiling and declarations inside if or when


From: Lennart Borgman
Subject: Byte compiling and declarations inside if or when
Date: Tue, 28 Dec 2004 13:57:15 +0100

I do not know whether this is the right place to ask this question but I
suspect it is so I will try. Please just tell me where to find the answer if
this is not the right place!


I am trying to rewrite some code so that it can be byte compiled (with
byte-compile-file). My first example is just a simple test (partly riped
from sys.el):

** w32-sys.el:

(eval-and-compile
  (defvar w32-system
    (memq system-type '(emx win32 w32 mswindows ms-dos windows-nt))
    "*Non-nil means Emacs is running on Windows 9x/NT."
    )
  )

Is this the way it should be done if I want to byte-compile-file this file?

My second example is a bit more complicated and uses the first example. I
have something like this in another source file:

(require 'w32-sys)
(eval-and-compile
(when w32-system

  (defun w32-integ-dired-execute(verb &optional show-flag)
    "Call ShellExecute with current file from dired."
    (let ((file-name (dired-get-filename)))
      (w32-shell-execute-with-msg verb file-name nil show-flag)))

))

I have put an eval-and-compile around the when clause but I do not know if
this is the way to do it. My goal is just that I want
w32-integ-dired-execute to be defined in the .elc-file if this is a
"w32-system", otherwise not. The code should also work if the .el source
file is loaded instead. (Please forget that you may not find this example
very realistic.) Is this the way to do it?

- Lennart





reply via email to

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