unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* configuring emacs as a programmer's editor
@ 2006-06-30  0:38 Ted
  2006-06-30  7:03 ` David Kastrup
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Ted @ 2006-06-30  0:38 UTC (permalink / raw)


OK, I have used emacs as just a clone of Notepad for quite a while.  I
know that is under-using it, but I found configuring it to be more
useful to me a bit onerous.  I find the emacs documentation a bit dense
on one side, and short of the details and examples I need on the other.

I have a basic .emacs file, appended below, that seems like it should
support most of the programming languages I use.  I constructed it by
copying and pasting portions of .emacs files I found published on the
web.

I need something that will work for me on both Windows XP and SUSE
Linux 10.  But on Windows, I have MS Visual Studio, and so need emacs
to support primarily SQL, Perl, PHP, while on Linux, I need it to
support these plus the C++ and fortran gcc compilers.  While I do a lot
of Java, I use Netbeans almost exclusively for my java programming.
Finally, I need to be able to specify whether to submit my SQL to
PostgreSQL or to MySQL, if that is possible.

I suppose I have two questions.  1) How do I modify the .emacs file
I've managed to cobble together to fully support my needs?  and 2)
Although I can get into perl mode (using cperl-mode, I think), by
loading or creating a perl script file, I find invariably that the run,
kill, next error, and check syntax items on the Perl submenu are
disabled.  Why?  And how do I fix that?  I have guessed that emacs is
largely written in, and configured using lisp, and that to really
understand this, I should learn lisp, but the time I have for that in a
significant way is not yet available, so lisp code, for this
fortran/C++,Java/SQL coder, is about as intelligible as Greek (which I
don't understand, being a unilingual anglophone).  There is only so
much time in a day and I can't get to everything I want to do.  :-(
I'd make better progress if I could find a resource that relates lisp
syntax and style to their counterparts in the languages I know, but
that is another issue.

For the present, I'll be content if someone could help me get emacs
configured on Windows and Linux to meet my proximate needs.

Thanks.

Ted

====my .emacs file==================
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs appearance
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set-background-color "white")
(set-foreground-color "black") ;; slategray
(set-cursor-color "red")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Display the time on the status line
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq display-time-24hr-format t)
(display-time)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Associate different modes with different file types.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defalias 'perl-mode 'cperl-mode)
(autoload 'c++-mode  "cc-mode"  "C++ Editing Mode"         t)
(autoload 'c-mode    "cc-mode"  "C Editing Mode"           t)
(autoload 'plsql-mode       "plsql"      "PL/SQL mode"
t)
(setq interpreter-mode-alist
      (append '(("perl"  . cperl-mode)
		("perl5" . cperl-mode)) interpreter-mode-alist))

(setq auto-mode-alist
      '(
        ("\\.bashrc\\'" . sh-mode)
        ("\\.bib\\'" . bibtex-mode)
        ("\\.c\\'" . c-mode)
        ("\\.cgi\\'" . python-mode)
        ("\\.cpp\\'" . c++-mode)
        ("\\.css\\'" . css-mode)
        ("\\.dtd\\'" . sgml-mode)
        ("\\.el\\'"  . emacs-lisp-mode)
        ("\\.emacs\\'" . emacs-lisp-mode)
        ("\\.es$" . c++-mode)
        ("\\.htm\\'" . html-mode)
        ("\\.html\\'" . xml-mode)
        ("\\.shtml\\'" . html-mode)
        ("\\.idl\\'" . c++-mode)
        ("\\.java\\'" . jde-mode)
		  ("\\.js$" . c++-mode)
        ("\\.odl\\'" . c++-mode)
        ("\\.py\\'" . python-mode)
        ("\\.php\\'" . php-mode)
        ("\\.phtml\\'" . php-mode)
        ("\\.pl\\'" . perl-mode)
        ("\\.properties\\'" . perl-mode)
        ("\\.py$" . python-mode)
        ("\\.sh\\'" . sh-mode)
        ("\\.sql\\'" . sql-mode)
        ("\\.text\\'" . text-mode)
        ("\\.txt\\'" . text-mode)
        ("\\.tex\\'" . latex-mode)
        ("\\.vm\\'" . emacs-lisp-mode)
        ("\\.wfcfg\\'" . perl-mode)
        ("\\.wsdd\\'" . xml-mode)
        ("\\.xml\\'" . xml-mode)
		  ))
(defun query-kill-emacs ()
  "Asks if you want to quit emacs before quiting."
  (interactive)
  (if (nth 1 (frame-list))
      (delete-frame)
    (if (y-or-n-p "Are you sure you want to quit? ")
	(save-buffers-kill-emacs)
      (message "Quit aborted."))))
(defun paren-match ()
  "Jumps to the paren matching the one under point,
and does nothing if there isn't one."
  (interactive)
  (cond
   ((looking-at "[({[]") (forward-sexp 1) (backward-char))
   ((looking-at "[]})]") (forward-char) (backward-sexp 1))
   (t           (message "Could not find matching paren."))) )

;; pretty-print hashes:
(if (fboundp 'maphash)
    (defun pp-hash (H)
      (let (s)
	(maphash
	 (lambda (K V)
	   (setq s (concat s (format "%S => \n%s" K (pp V))))) H) s)))

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

* Re: configuring emacs as a programmer's editor
  2006-06-30  0:38 configuring emacs as a programmer's editor Ted
@ 2006-06-30  7:03 ` David Kastrup
  2006-06-30  7:04 ` Andreas Roehler
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: David Kastrup @ 2006-06-30  7:03 UTC (permalink / raw)


"Ted" <r.ted.byers@rogers.com> writes:

> OK, I have used emacs as just a clone of Notepad for quite a while.  I
> know that is under-using it, but I found configuring it to be more
> useful to me a bit onerous.  I find the emacs documentation a bit dense
> on one side, and short of the details and examples I need on the other.
>
> I have a basic .emacs file, appended below, that seems like it
> should support most of the programming languages I use.  I
> constructed it by copying and pasting portions of .emacs files I
> found published on the web.

That is the worst thing one can possibly do.  You'll get a hotch potch
of what various people with various skills considered to be a good
idea for various versions of Emacs.

Instead, start from an empty .emacs and add things you need by
referring to the manual and/or using M-x customize RET.

The Emacs manual also contains a section about configuration.

> (setq auto-mode-alist
>       '(
>         ("\\.bashrc\\'" . sh-mode)

VERY VERY VERY bad idea: you destroy all of Emacs' built-in knowledge
about types.  Instead you should add only those things that you need
specifically to the front of auto-mode-alist.

Probably even nothing is necessary here.
>       (delete-frame)
>     (if (y-or-n-p "Are you sure you want to quit? ")
> 	(save-buffers-kill-emacs)
>       (message "Quit aborted."))))
> (defun paren-match ()
>   "Jumps to the paren matching the one under point,
> and does nothing if there isn't one."
>   (interactive)
>   (cond
>    ((looking-at "[({[]") (forward-sexp 1) (backward-char))
>    ((looking-at "[]})]") (forward-char) (backward-sexp 1))
>    (t           (message "Could not find matching paren."))) )
>
> ;; pretty-print hashes:
> (if (fboundp 'maphash)
>     (defun pp-hash (H)
>       (let (s)
> 	(maphash
> 	 (lambda (K V)
> 	   (setq s (concat s (format "%S => \n%s" K (pp V))))) H) s)))
>

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: configuring emacs as a programmer's editor
  2006-06-30  0:38 configuring emacs as a programmer's editor Ted
  2006-06-30  7:03 ` David Kastrup
@ 2006-06-30  7:04 ` Andreas Roehler
  2006-06-30  8:02   ` Le Wang
  2006-06-30  7:37 ` Le Wang
  2006-07-03 22:09 ` Jason Rumney
  3 siblings, 1 reply; 14+ messages in thread
From: Andreas Roehler @ 2006-06-30  7:04 UTC (permalink / raw)


Ted wrote:

> OK, I have used emacs as just a clone of Notepad for quite a
> while.  I know that is under-using it, but I found configuring
> it to be more
> useful to me a bit onerous.  I find the emacs documentation a
> bit dense on one side, and short of the details and examples I
> need on the other.
>


Agree and don't agree. Beside the Emacs manual there is
Elisp manual with a rather detailed explanation of the
underlying concepts, vars and functions.



> I have a basic .emacs file, appended below, that seems like it
> should
> support most of the programming languages I use.  I constructed
> it by copying and pasting portions of .emacs files I found
> published on the web.
> 
> I need something that will work for me on both Windows XP and
> SUSE
> Linux 10.  


Probably you will or should use two different init
files: If you are in windows the .emacs from Linux will
not be known there. Also the windows Emacs is a
different machine as such AFAIU.

(Basically its possible the have a combined init file at
the windows part and read it in from Linux, but that
will complicate the task.)


> But on Windows, I have MS Visual Studio, and so need 
> emacs to support primarily SQL, Perl, PHP, while on Linux, I
> need it to
> support these plus the C++ and fortran gcc compilers.  While I
> do a lot of Java, I use Netbeans almost exclusively for my java
> programming. Finally, I need to be able to specify whether to
> submit my SQL to PostgreSQL or to MySQL, if that is possible.
> 
> I suppose I have two questions.  1) How do I modify the .emacs
> file
> I've managed to cobble together to fully support my needs?  and
> 2) Although I can get into perl mode (using cperl-mode, I
> think), by loading or creating a perl script file, I find
> invariably that the run, kill, next error, and check syntax
> items on the Perl submenu are
> disabled.  Why?  And how do I fix that?  

Programs may partly rely at system facilities as the
Linux-Shell - and respective windows facilities.

To solve a problem, it's necessary to know where you
are, which modes are on, which commands have been
called last etc.

Suggest to use the bug-report facilities (without
sending it)

M-x report-emacs-bug

just after the command failed. This way a lot of
useful information is collected, which may help.

> emacs is largely written in, and configured using lisp, and
> that to really understand this, I should learn lisp, but the
> time I have for that in a significant way is not yet available,
> so lisp code, for this fortran/C++,Java/SQL coder, is about as
> intelligible as Greek (which I
> don't understand, being a unilingual anglophone).  There is
> only so
> much time in a day and I can't get to everything I want to do. 
> :-( I'd make better progress if I could find a resource that
> relates lisp syntax and style to their counterparts in the
> languages I know, but that is another issue.

It's understood. At the other side: Without elisp knowledge it's
possible, with it starts the fun. (And much more fun 
as I expected.)

> For the present, I'll be content if someone could help me get
> emacs configured on Windows and Linux to meet my proximate
> needs.


> Thanks.
> 
> Ted
> 
> ====my .emacs file==================
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;; Emacs appearance
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (set-background-color "white")
> (set-foreground-color "black") ;; slategray
> (set-cursor-color "red")
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;; Display the time on the status line
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (setq display-time-24hr-format t)
> (display-time)
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;; Associate different modes with different file types.
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (defalias 'perl-mode 'cperl-mode)
> (autoload 'c++-mode  "cc-mode"  "C++ Editing Mode"         t)
> (autoload 'c-mode    "cc-mode"  "C Editing Mode"           t)
> (autoload 'plsql-mode       "plsql"      "PL/SQL mode"
> t)
> (setq interpreter-mode-alist
>       (append '(("perl"  . cperl-mode)
> ("perl5" . cperl-mode)) interpreter-mode-alist))
> 
> (setq auto-mode-alist
>       '(
>         ("\\.bashrc\\'" . sh-mode)
>         ("\\.bib\\'" . bibtex-mode)
>         ("\\.c\\'" . c-mode)
>         ("\\.cgi\\'" . python-mode)
>         ("\\.cpp\\'" . c++-mode)
>         ("\\.css\\'" . css-mode)
>         ("\\.dtd\\'" . sgml-mode)
>         ("\\.el\\'"  . emacs-lisp-mode)
>         ("\\.emacs\\'" . emacs-lisp-mode)
>         ("\\.es$" . c++-mode)
>         ("\\.htm\\'" . html-mode)
>         ("\\.html\\'" . xml-mode)
>         ("\\.shtml\\'" . html-mode)
>         ("\\.idl\\'" . c++-mode)
>         ("\\.java\\'" . jde-mode)
> ("\\.js$" . c++-mode)
>         ("\\.odl\\'" . c++-mode)
>         ("\\.py\\'" . python-mode)
>         ("\\.php\\'" . php-mode)
>         ("\\.phtml\\'" . php-mode)
>         ("\\.pl\\'" . perl-mode)
>         ("\\.properties\\'" . perl-mode)
>         ("\\.py$" . python-mode)
>         ("\\.sh\\'" . sh-mode)
>         ("\\.sql\\'" . sql-mode)
>         ("\\.text\\'" . text-mode)
>         ("\\.txt\\'" . text-mode)
>         ("\\.tex\\'" . latex-mode)
>         ("\\.vm\\'" . emacs-lisp-mode)
>         ("\\.wfcfg\\'" . perl-mode)
>         ("\\.wsdd\\'" . xml-mode)
>         ("\\.xml\\'" . xml-mode)
> ))


What's with the auto-mode-alist.

Usually it's defined by files.el and
should be OK. Are there reasons to redefine it? 

__
Andreas Roehler


PS:
Myself I'm still exploring Emacs and
interested in questions of convenience and usability.

Please feel free to send your precise questions with
email too. I'm using 

GNU Emacs 22.0.50.2 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) 
at Suse 10.0. Windows rather not.


> (defun query-kill-emacs ()
>   "Asks if you want to quit emacs before quiting."
>   (interactive)
>   (if (nth 1 (frame-list))
>       (delete-frame)
>     (if (y-or-n-p "Are you sure you want to quit? ")
> (save-buffers-kill-emacs)
>       (message "Quit aborted."))))
> (defun paren-match ()
>   "Jumps to the paren matching the one under point,
> and does nothing if there isn't one."
>   (interactive)
>   (cond
>    ((looking-at "[({[]") (forward-sexp 1) (backward-char))
>    ((looking-at "[]})]") (forward-char) (backward-sexp 1))
>    (t           (message "Could not find matching paren."))) )
> 
> ;; pretty-print hashes:
> (if (fboundp 'maphash)
>     (defun pp-hash (H)
>       (let (s)
> (maphash
> (lambda (K V)
> (setq s (concat s (format "%S => \n%s" K (pp V))))) H) s)))

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

* Re: configuring emacs as a programmer's editor
  2006-06-30  0:38 configuring emacs as a programmer's editor Ted
  2006-06-30  7:03 ` David Kastrup
  2006-06-30  7:04 ` Andreas Roehler
@ 2006-06-30  7:37 ` Le Wang
  2006-06-30 16:14   ` Ted
  2006-07-03 22:09 ` Jason Rumney
  3 siblings, 1 reply; 14+ messages in thread
From: Le Wang @ 2006-06-30  7:37 UTC (permalink / raw)


Ted wrote:
> OK, I have used emacs as just a clone of Notepad for quite a while.  I
> know that is under-using it, but I found configuring it to be more
> useful to me a bit onerous.  I find the emacs documentation a bit dense
> on one side, and short of the details and examples I need on the other.
>
> I have a basic .emacs file, appended below, that seems like it should
> support most of the programming languages I use.  I constructed it by
> copying and pasting portions of .emacs files I found published on the
> web.
>
> I need something that will work for me on both Windows XP and SUSE
> Linux 10.  But on Windows, I have MS Visual Studio, and so need emacs
> to support primarily SQL, Perl, PHP, while on Linux, I need it to
> support these plus the C++ and fortran gcc compilers.  While I do a lot
> of Java, I use Netbeans almost exclusively for my java programming.
> Finally, I need to be able to specify whether to submit my SQL to
> PostgreSQL or to MySQL, if that is possible.
>
> I suppose I have two questions.  1) How do I modify the .emacs file
> I've managed to cobble together to fully support my needs?  and 2)
> Although I can get into perl mode (using cperl-mode, I think), by
> loading or creating a perl script file, I find invariably that the run,
> kill, next error, and check syntax items on the Perl submenu are
> disabled.  Why?  And how do I fix that?  I have guessed that emacs is
> largely written in, and configured using lisp, and that to really
> understand this, I should learn lisp

You don't need to be an Emacs lisp master to customize your Emacs.
Your .emacs file looks like a good start.  Although there are some
obvious problems that you'll easily be able to fix, once you have a
tiny bit of lisp under your belt.  I actually find that there is an
abundance of material to get you started in lisp, and it doesn't take
that much time to get the basics down.

See:

1.  Google groups for past q/a

2.  Emacs Wiki

3.  http://www.gnu.org/software/emacs/emacs-lisp-intro/

If you have specific questions, ask them, and people will try to help.
The most important thing is to just jump in and get over that "lisp is
so hard" hump.  It's really not.  It's a different way of thinking
about programming, and I find that knowing Emacs lisp (I'm a novice
myself) actually helps me think about other code I write in different
ways.  It's kind of cool that way.

The great thing about Emacs is that it's self documenting, so the
trivial questions you have can be addressed by actually exploring Emacs
yourself.

For example, your cperl-mode compile commands are missing.  So you
begin by asking Emacs about "cperl-mode":

<C-h> f
cperl-mode

And Emacs shows you the help text associated this command  (See the
wiki for other ways Emacs documents itself, including the powerful
apropos features).

Now, you click on the underlined `cperl-mode', and open up the source
code.  You search for the name a missing menu item -- "Check Syntax",
and you find:

	  ["Check syntax" cperl-check-syntax (fboundp 'mode-compile)]

This occurs in the `easy-menu-define' context, so you suspect that this
is where the menu item is defined.  Now what do these tokens mean?  The
first string is obvious.  Emacs tells you "cperl-check-syntax" is the
actual command that triggers the function.       (<C-h> f
cperl-check-syntax)  And "fboundp" checks if a feature is present.  You
evaluate the "(fboundp 'mode-compile)" sexp by placing the cursor on
"]" and pressinng <C-x><C-e>, and find that it's nil, meaning that the
"mode-compile" is missing.  You put it all together and parse this line
as -- define "Check Syntax" menu item, invoking `cperl-check-syntax' if
`mode-compile' feature is present.  Obviously it's failing because
`mode-compile' is missing.  You then do a web search and find that it's
available here:  "http://www.tls.cena.fr/~boubaker/Emacs/".  You follow
the instructions on the web page and install the package.  Voila.  Now
you know Emacs as more than a "Notepad clone", and it all builds up
from there.

hth.


--
Le

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

* Re: configuring emacs as a programmer's editor
  2006-06-30  7:04 ` Andreas Roehler
@ 2006-06-30  8:02   ` Le Wang
  2006-06-30 12:13     ` Eli Zaretskii
       [not found]     ` <mailman.3562.1151669638.9609.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 14+ messages in thread
From: Le Wang @ 2006-06-30  8:02 UTC (permalink / raw)



Andreas Roehler wrote:
> Ted wrote:
>
>
> Probably you will or should use two different init
> files: If you are in windows the .emacs from Linux will
> not be known there. Also the windows Emacs is a
> different machine as such AFAIU.
>
> (Basically its possible the have a combined init file at
> the windows part and read it in from Linux, but that
> will complicate the task.)

No.  Emacs does a good job of providing the glue that makes it OS
agnostic.  See Google groups to address specific problems you come
across.  There is no reason to maintain two init files.  Worst comes to
worst:

(if (string-match "win" (prin1-to-string system-type))
    ;; windows form
  ;; unix forms
)


<snip>

> What's with the auto-mode-alist.
>
> Usually it's defined by files.el and
> should be OK. Are there reasons to redefine it?

No.  This is a bad BAD idea.

--
Le

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

* Re: configuring emacs as a programmer's editor
  2006-06-30  8:02   ` Le Wang
@ 2006-06-30 12:13     ` Eli Zaretskii
       [not found]     ` <mailman.3562.1151669638.9609.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2006-06-30 12:13 UTC (permalink / raw)


> From: "Le Wang" <l26wang@gmail.com>
> Date: 30 Jun 2006 01:02:40 -0700
> 
> (if (string-match "win" (prin1-to-string system-type))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It's much easier to use (symbol-name system-type).  That's if you
really need the string representation of system-type; you could simply
use (eq system-type 'windows-nt) or (memq system-type '(windows-nt cygwin))
instead.

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

* Re: configuring emacs as a programmer's editor
  2006-06-30  7:37 ` Le Wang
@ 2006-06-30 16:14   ` Ted
  2006-07-01 23:19     ` Le Wang
                       ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Ted @ 2006-06-30 16:14 UTC (permalink / raw)



Le Wang wrote:
> Ted wrote:
> `mode-compile' is missing.  You then do a web search and find that it's
> available here:  "http://www.tls.cena.fr/~boubaker/Emacs/".  You follow

Thanks all.  I found, with a little experimenting, that I didn't need
much of what I thought I needed.

I am using version 21.3 of emacs, if that matters.

I didn't find mode-compile.el on my system, and so I downloaded it from
the site you cite above.  I tried to byte compile within emacs, as
instructed, but no mode-compile.elc is made.  The output I get is:

Compiling file c:/emacs-21.3/mode-compile.el at Fri Jun 30 11:54:37
2006
  !! End of file during parsing

This looks like an error message, but it doesn't make sense given that
the last line in the file is:

;;; mode-compile.el ends here

This tells me that the file I'm working with has not been truncated.

Why does byte-compiling this file fail?  Is the file on the above site
defective?  Is the file available elsewhere?

Ted

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

* Re: configuring emacs as a programmer's editor
       [not found]     ` <mailman.3562.1151669638.9609.help-gnu-emacs@gnu.org>
@ 2006-07-01  4:20       ` Le Wang
  0 siblings, 0 replies; 14+ messages in thread
From: Le Wang @ 2006-07-01  4:20 UTC (permalink / raw)


Eli Zaretskii wrote:
> > From: "Le Wang" <l26wang@gmail.com>
> > Date: 30 Jun 2006 01:02:40 -0700
> >
> > (if (string-match "win" (prin1-to-string system-type))
>                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> It's much easier to use (symbol-name system-type).  That's if you
> really need the string representation of system-type; you could simply
> use (eq system-type 'windows-nt) or (memq system-type '(windows-nt cygwin))
> instead.

Very good point.  I didn't know about `symbol-name'.  I suggested
regular expression here because I use it in a macro, so the slowdown
only happens at compile time.  But I didn't want to scare Ted off with
the slightly more brackety version. ;-)

(defmacro Init-system-type-load (&rest args)
  "Evaluates to appropriate form based on `system-type'

Takes args in this way

  (Init-system-load (\"regex\" (form1a) (form1b)) (\"string2\"
(forms2a)))

t will match anything."
  (dolist (arg args)
    (when (or (eq (car arg) t)
              (string-match (car arg) (symbol-name system-type)))
      (return (cons 'progn (cdr arg))))))

--
Le

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

* Re: configuring emacs as a programmer's editor
  2006-06-30 16:14   ` Ted
@ 2006-07-01 23:19     ` Le Wang
  2006-07-02  3:46     ` B. T. Raven
  2006-07-03 20:15     ` Ted
  2 siblings, 0 replies; 14+ messages in thread
From: Le Wang @ 2006-07-01 23:19 UTC (permalink / raw)



Ted wrote:
>
> I didn't find mode-compile.el on my system, and so I downloaded it from
> the site you cite above.  I tried to byte compile within emacs, as
> instructed, but no mode-compile.elc is made.  The output I get is:
>
> Compiling file c:/emacs-21.3/mode-compile.el at Fri Jun 30 11:54:37
> 2006
>   !! End of file during parsing

I found many threads on Google groups by searching for "Emacs + End of
file during parsing"  Did non of the proposed solutions work for you?

--
Le

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

* Re: configuring emacs as a programmer's editor
  2006-06-30 16:14   ` Ted
  2006-07-01 23:19     ` Le Wang
@ 2006-07-02  3:46     ` B. T. Raven
  2006-07-02  8:32       ` Tim X
  2006-07-03 20:15     ` Ted
  2 siblings, 1 reply; 14+ messages in thread
From: B. T. Raven @ 2006-07-02  3:46 UTC (permalink / raw)



"Ted" <r.ted.byers@rogers.com> wrote in message
news:1151684092.236583.270470@b68g2000cwa.googlegroups.com...
>
> Le Wang wrote:
> > Ted wrote:
> > `mode-compile' is missing.  You then do a web search and find that
it's
> > available here:  "http://www.tls.cena.fr/~boubaker/Emacs/".  You
follow
>
> Thanks all.  I found, with a little experimenting, that I didn't need
> much of what I thought I needed.
>
> I am using version 21.3 of emacs, if that matters.
>
> I didn't find mode-compile.el on my system, and so I downloaded it from
> the site you cite above.  I tried to byte compile within emacs, as
> instructed, but no mode-compile.elc is made.  The output I get is:
>
> Compiling file c:/emacs-21.3/mode-compile.el at Fri Jun 30 11:54:37
> 2006
>   !! End of file during parsing
>
> This looks like an error message, but it doesn't make sense given that
> the last line in the file is:
>
> ;;; mode-compile.el ends here
>
> This tells me that the file I'm working with has not been truncated.
>
> Why does byte-compiling this file fail?  Is the file on the above site
> defective?  Is the file available elsewhere?
>
> Ted
>

I removed 21 ^L's from the source and the byte-compilation went to
completion with the following warnings:

Compiling file d:/EMACS/emacs-21.3/site-lisp/mc.el at Sat Jul 01 22:39:21
2006
  ** reference to free variable efs-remote-shell-file-name
  ** `(fboundp (quote eval-when-compile))' called for effect
  ** `(fboundp (quote eval-when-compile))' called for effect
  ** The following functions are not known to be defined: console-type,
    device-type, mc--compile-sav, mc--frame-live-p, mc--select-frame,
    mc--make-frame, mc--make-frame-visible, mc--raise-frame,
    byte-compile-buffer, locate-file, mc--member, efs-ftp-path,
    mc--run-hooks


The front matter of the .el looks like this:

;;   Last modified: 2003/04/01 13:52:47
;;   Version: 2.28
;;   Keywords: compile, compilation, modes, languages
;;   Tested for:
;;     XEmacs (Lucid GNU Emacs) >= 19.10
;;     Must work with FSF GNU Emacs > 19.31 ;-)


Maybe the smiley face has a tongue in cheek.

Ed.

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

* Re: configuring emacs as a programmer's editor
  2006-07-02  3:46     ` B. T. Raven
@ 2006-07-02  8:32       ` Tim X
  0 siblings, 0 replies; 14+ messages in thread
From: Tim X @ 2006-07-02  8:32 UTC (permalink / raw)


"B. T. Raven" <ecinmn@alcisp.com> writes:

> "Ted" <r.ted.byers@rogers.com> wrote in message
> news:1151684092.236583.270470@b68g2000cwa.googlegroups.com...
>>
>> Le Wang wrote:
>> > Ted wrote:
>> > `mode-compile' is missing.  You then do a web search and find that
> it's
>> > available here:  "http://www.tls.cena.fr/~boubaker/Emacs/".  You
> follow
>>
>> Thanks all.  I found, with a little experimenting, that I didn't need
>> much of what I thought I needed.
>>
>> I am using version 21.3 of emacs, if that matters.
>>
>> I didn't find mode-compile.el on my system, and so I downloaded it from
>> the site you cite above.  I tried to byte compile within emacs, as
>> instructed, but no mode-compile.elc is made.  The output I get is:
>>
>> Compiling file c:/emacs-21.3/mode-compile.el at Fri Jun 30 11:54:37
>> 2006
>>   !! End of file during parsing
>>
>> This looks like an error message, but it doesn't make sense given that
>> the last line in the file is:
>>
>> ;;; mode-compile.el ends here
>>
>> This tells me that the file I'm working with has not been truncated.
>>
>> Why does byte-compiling this file fail?  Is the file on the above site
>> defective?  Is the file available elsewhere?
>>

That error message often means there is a missing close ) somewhere.

>>
>
> I removed 21 ^L's from the source and the byte-compilation went to
> completion with the following warnings:
>
Thats very odd - it is common to have ^L in elisp source files as
these are often used as page breaks and provide a convenient way to
jump around by "pages". 


> Compiling file d:/EMACS/emacs-21.3/site-lisp/mc.el at Sat Jul 01 22:39:21
> 2006

I notice that not only is this a different path (drive) to the
previous one you were using, it is also a completely different
filename (mc.el rather than mode-compile.el). 

>   ** reference to free variable efs-remote-shell-file-name
>   ** `(fboundp (quote eval-when-compile))' called for effect
>   ** `(fboundp (quote eval-when-compile))' called for effect
>   ** The following functions are not known to be defined: console-type,
>     device-type, mc--compile-sav, mc--frame-live-p, mc--select-frame,
>     mc--make-frame, mc--make-frame-visible, mc--raise-frame,
>     byte-compile-buffer, locate-file, mc--member, efs-ftp-path,
>     mc--run-hooks
>
>

The above are not errors, but warnings. The "reference to free
variable" means there is a (setq something ....) where there has been
no (defvar something). It is possible the defvar is done in a related
mode which at the time of compilation had not been loaded. The
warnings regarding functions not known to be defined may also be
nothing to worry about. It is just warning you that when the file was
being compiled, there was no visible definition for these functions,
which again may just indicate they have not yet been loaded (though
some of them do look a bit suspect). 

> The front matter of the .el looks like this:
>
> ;;   Last modified: 2003/04/01 13:52:47
> ;;   Version: 2.28
> ;;   Keywords: compile, compilation, modes, languages
> ;;   Tested for:
> ;;     XEmacs (Lucid GNU Emacs) >= 19.10
> ;;     Must work with FSF GNU Emacs > 19.31 ;-)
>
>
> Maybe the smiley face has a tongue in cheek.
>
Well, it is winking!

Most of the time, you do not have to compile a *.el file to use it.
this is normally only done to improve performance. So, before trying
to compile the file, see ifyou can successfully load it and use it.
then, once you know its working, worry about getting it to compile.
Note you will need to remove the .elc version if it is there. Also
note that if you have renamed the file to mc.el, you can get into
trouble with loading it - the (require 'mode-compile) directive looks
for a file called mode-compile.elc or mode-compile.el. If you rename
the file, emacs won't find it.

I suspect from rading this thread and the way you are operating, you
are attempting to find quick and easy short cuts to get to where you
want to be without having to put time into learning more about emacs.
I can understand this - after all, its a tool you want to use.
However, you are also trying to setup emacs as an experts tool rather
than getting to know how it works "out of the box" and I suspect ou
will actually spend more time chasing your tail than if you put aside
the time to read the manuals. I do understand this approach and for
many systems, it can be quite fruitful - but not for Emacs.

There are no real short-cuts here. Emacs is extremely powerful and
there are thousands of customizations and add-ons out there ranging
from amazingly powerful to unbelievably badly implemented and broken.
You need at least a basic familiarity in order to identify the crap
from the gold. One of the great things about elisp is that its syntax
is extremely easy and it doesn't take long to understand what is going
on - lisp is really easy to learn, but quite difficult to master. The
good news is you don't need to master it to use it to great benefit. 

>From memory, you wanted to work with emacs under both Linux and
Windows. I would recommend getting the Linux/Unix environment sorted
first. This is probably Emacs' more 'native' platform and getting
things working correctly there first will avoid you spending hours and
hours tyring to fix something only to find out that the code you have
doesn't work under windows. 

-- 
tcross (at) rapttech dot com dot au

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

* Re: configuring emacs as a programmer's editor
  2006-06-30 16:14   ` Ted
  2006-07-01 23:19     ` Le Wang
  2006-07-02  3:46     ` B. T. Raven
@ 2006-07-03 20:15     ` Ted
  2006-07-04  8:34       ` Tim X
  2 siblings, 1 reply; 14+ messages in thread
From: Ted @ 2006-07-03 20:15 UTC (permalink / raw)



Ted wrote:
> [snip]
> Compiling file c:/emacs-21.3/mode-compile.el at Fri Jun 30 11:54:37
> 2006
>   !! End of file during parsing
>
> This looks like an error message, but it doesn't make sense given that
> the last line in the file is:
>
> ;;; mode-compile.el ends here
>
> This tells me that the file I'm working with has not been truncated.
>
> Why does byte-compiling this file fail?  Is the file on the above site
> defective?  Is the file available elsewhere?
>
I found out why.  When I go to the website and save the file directly
from within Internet Explorer, I invariably get the end of file
nonsense.  I also have to delete some HTML tags both at the beginning
and end of the file, along with the ^L characters.  If, instead, I
right-click the web page and select "view source", I get a window in
which there are no HTML tags, but I still have to delete the ^L
characters.  But in doing this, the file compiles properly, with only
the warnings you mentioned.  Now emacs behaves as I wish, at least for
Perl programming.

Now, all I need is to find out how to slightly alter how SQL is
handled.  I'd like to be able to use Emacs as a client for MySQL and
for PostgreSQL.  Can Emacs be set up to ease submitting SQL statements
to either MySQL or PostgreSQL as I wish?  If so, how?  I have done a
number of searches on this, but the signal to noise ratio is extremely
low.

Thanks,

Ted

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

* Re: configuring emacs as a programmer's editor
  2006-06-30  0:38 configuring emacs as a programmer's editor Ted
                   ` (2 preceding siblings ...)
  2006-06-30  7:37 ` Le Wang
@ 2006-07-03 22:09 ` Jason Rumney
  3 siblings, 0 replies; 14+ messages in thread
From: Jason Rumney @ 2006-07-03 22:09 UTC (permalink / raw)


"Ted" <r.ted.byers@rogers.com> writes:

> I suppose I have two questions.  1) How do I modify the .emacs file
> I've managed to cobble together to fully support my needs?

The best way is probably to throw it out and start again.

Fire up customize, and go through the various options that interest
you. This will teach you more about Emacs than blindly copying
snippets of other people's .emacs files, and the result will work,
without requiring a whole newsgroup to help with debugging it.

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

* Re: configuring emacs as a programmer's editor
  2006-07-03 20:15     ` Ted
@ 2006-07-04  8:34       ` Tim X
  0 siblings, 0 replies; 14+ messages in thread
From: Tim X @ 2006-07-04  8:34 UTC (permalink / raw)


"Ted" <r.ted.byers@rogers.com> writes:

> Ted wrote:
>> [snip]
>> Compiling file c:/emacs-21.3/mode-compile.el at Fri Jun 30 11:54:37
>> 2006
>>   !! End of file during parsing
>>
>> This looks like an error message, but it doesn't make sense given that
>> the last line in the file is:
>>
>> ;;; mode-compile.el ends here
>>
>> This tells me that the file I'm working with has not been truncated.
>>
>> Why does byte-compiling this file fail?  Is the file on the above site
>> defective?  Is the file available elsewhere?
>>
> I found out why.  When I go to the website and save the file directly
> from within Internet Explorer, I invariably get the end of file
> nonsense.  I also have to delete some HTML tags both at the beginning
> and end of the file, along with the ^L characters.  If, instead, I
> right-click the web page and select "view source", I get a window in
> which there are no HTML tags, but I still have to delete the ^L
> characters.  But in doing this, the file compiles properly, with only
> the warnings you mentioned.  Now emacs behaves as I wish, at least for
> Perl programming.
>
> Now, all I need is to find out how to slightly alter how SQL is
> handled.  I'd like to be able to use Emacs as a client for MySQL and
> for PostgreSQL.  Can Emacs be set up to ease submitting SQL statements
> to either MySQL or PostgreSQL as I wish?  If so, how?  I have done a
> number of searches on this, but the signal to noise ratio is extremely
> low.
>

Emacs comes with sql.el - an sql mode which will allow you to send sql
statements to various database backends including postgres, mysql,
oracle, ms sql server etc. 

,----[ C-h f sql-mode RET ]
| sql-mode is an interactive autoloaded Lisp function in `sql'.
| (sql-mode)
| 
| Major mode to edit SQL.
| 
| You can send SQL statements to the SQLi buffer using
| M-x sql-send-region.  Such a buffer must exist before you can do this.
| See `sql-help' on how to create SQLi buffers.
| 
| 
| Uses keymap "sql-mode-map", which is not currently defined.
| 
| Customization: Entry to this mode runs the `sql-mode-hook'.
| 
| When you put a buffer in SQL mode, the buffer stores the last SQLi
| buffer created as its destination in the variable `sql-buffer'.  This
| will be the buffer M-x sql-send-region sends the region to.  If this
| SQLi buffer is killed, M-x sql-send-region is no longer able to
| determine where the strings should be sent to.  You can set the
| value of `sql-buffer' using M-x sql-set-sqli-buffer.
| 
| For information on how to create multiple SQLi buffers, see
| `sql-interactive-mode'.
| 
| Note that SQL doesn't have an escape character unless you specify
| one.  If you specify backslash as escape character in SQL,
| you must tell Emacs.  Here's how to do that in your `~/.emacs' file:
| 
| (add-hook 'sql-mode-hook
|           (lambda ()
| 	    (modify-syntax-entry ?\\ "." sql-mode-syntax-table)))
`----

Tim

-- 
tcross (at) rapttech dot com dot au

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

end of thread, other threads:[~2006-07-04  8:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-30  0:38 configuring emacs as a programmer's editor Ted
2006-06-30  7:03 ` David Kastrup
2006-06-30  7:04 ` Andreas Roehler
2006-06-30  8:02   ` Le Wang
2006-06-30 12:13     ` Eli Zaretskii
     [not found]     ` <mailman.3562.1151669638.9609.help-gnu-emacs@gnu.org>
2006-07-01  4:20       ` Le Wang
2006-06-30  7:37 ` Le Wang
2006-06-30 16:14   ` Ted
2006-07-01 23:19     ` Le Wang
2006-07-02  3:46     ` B. T. Raven
2006-07-02  8:32       ` Tim X
2006-07-03 20:15     ` Ted
2006-07-04  8:34       ` Tim X
2006-07-03 22:09 ` Jason Rumney

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