unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Byte compiling and declarations inside if or when
@ 2004-12-28 12:57 Lennart Borgman
  2004-12-28 17:24 ` Lennart Borgman
  0 siblings, 1 reply; 2+ messages in thread
From: Lennart Borgman @ 2004-12-28 12:57 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Byte compiling and declarations inside if or when
  2004-12-28 12:57 Byte compiling and declarations inside if or when Lennart Borgman
@ 2004-12-28 17:24 ` Lennart Borgman
  0 siblings, 0 replies; 2+ messages in thread
From: Lennart Borgman @ 2004-12-28 17:24 UTC (permalink / raw)


Please excuse me and forget this for a while. I am at the moment unable to
reproduce what I saw yesterday. For some reason w32-system was not bound
after require (when compiling if I remember correctly) if I did not use
eval-and-compile. Today I see no such thing.

I feel confused. I was experimenting with batch-byte-compile,
batch-recompile-dir and byte-compile-file. I am now using batch-byte-compile
and compile the files one by one (as suggested in lisp/makefile, I did not
remember to do this at first yesterday).

And I forgot to mention I was using 21.3.1 when doing this.

- Lennart


----- Original Message ----- 
From: "Lennart Borgman" <lennart.borgman.073@student.lu.se>

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-28 17:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-28 12:57 Byte compiling and declarations inside if or when Lennart Borgman
2004-12-28 17:24 ` Lennart Borgman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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