all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* New $TERM init code
@ 2005-07-29 20:04 Stefan Monnier
  2005-07-29 23:56 ` Dan Nicolaescu
  2005-09-12 15:51 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Monnier @ 2005-07-29 20:04 UTC (permalink / raw)



How 'bout the patch below which allows terminal-init-$TERM to be autoloaded
and/or defined elsewhere than in term/$TERM.el (e.g. it can be defined in
~/.emacs, or a single term/foo.el can define both terminal-init-foo-bar and
terminal-init-foo-baz, ...)?


        Stefan


--- orig/lisp/startup.el
+++ mod/lisp/startup.el
@@ -1004,14 +1004,21 @@
                   (not (load (concat term-file-prefix term) t t)))
         ;; Strip off last hyphen and what follows, then try again
         (setq term
-              (if (setq hyphend (string-match "[-_][^-_]+$" term))
+              (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
                   (substring term 0 hyphend)
                 nil)))
-      (when term
+      (setq term (getenv "TERM"))
+      (while term
 	;; The terminal file has been loaded, now call the terminal
 	;; specific initialization function.
 	(let ((term-init-func (intern-soft (concat "terminal-init-" term))))
-	  (when (fboundp term-init-func)
+	  (if (not (fboundp term-init-func))
+              ;; Strip off last hyphen and what follows, then try again
+              (setq term
+                    (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
+                        (substring term 0 hyphend)
+                      nil))
+            (setq term nil)
 	    (funcall term-init-func))))))
 
   ;; Update the out-of-memory error message based on user's key bindings

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

* Re: New $TERM init code
  2005-07-29 20:04 New $TERM init code Stefan Monnier
@ 2005-07-29 23:56 ` Dan Nicolaescu
  2005-09-12 15:51 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Nicolaescu @ 2005-07-29 23:56 UTC (permalink / raw)
  Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

    How 'bout the patch below which allows terminal-init-$TERM to be autoloaded
    and/or defined elsewhere than in term/$TERM.el (e.g. it can be defined in
    ~/.emacs, or a single term/foo.el can define both terminal-init-foo-bar and
    terminal-init-foo-baz, ...)?


            Stefan


    --- orig/lisp/startup.el
    +++ mod/lisp/startup.el
    @@ -1004,14 +1004,21 @@
                       (not (load (concat term-file-prefix term) t t)))
             ;; Strip off last hyphen and what follows, then try again
             (setq term
    -              (if (setq hyphend (string-match "[-_][^-_]+$" term))
    +              (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
                       (substring term 0 hyphend)
                     nil)))
    -      (when term
    +      (setq term (getenv "TERM"))
    +      (while term

Wouldn't it be better to have this loop before the "load" loop? (1)
Or if it's after only loop if the "load" loop didn't find a terminal
file? 

Doing it the (1) way would DTRT for the multi-tty branch, it would
avoid loading the terminal file iff the corresponding terminal-init-
function is defined, which would happen after connecting the first
time from a terminal type.

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

* Re: New $TERM init code
  2005-07-29 20:04 New $TERM init code Stefan Monnier
  2005-07-29 23:56 ` Dan Nicolaescu
@ 2005-09-12 15:51 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2005-09-12 15:51 UTC (permalink / raw)


>     --- orig/lisp/startup.el
>     +++ mod/lisp/startup.el
>     @@ -1004,14 +1004,21 @@
>                        (not (load (concat term-file-prefix term) t t)))
>              ;; Strip off last hyphen and what follows, then try again
>              (setq term
>     -              (if (setq hyphend (string-match "[-_][^-_]+$" term))
>     +              (if (setq hyphend (string-match "[-_][^-_]+\\'" term))
>                        (substring term 0 hyphend)
>                      nil)))
>     -      (when term
>     +      (setq term (getenv "TERM"))
>     +      (while term

Installed.

> Wouldn't it be better to have this loop before the "load" loop? (1)
> Or if it's after only loop if the "load" loop didn't find a terminal
> file? 

I don't think so.  The reason is that you may have a file term/foo.el which
you've already loaded and which defines terminal-init-foo and then a file
term/foo-bar.el (which defines terminal-init-foo-bar) which you haven't yet
loaded: you do want to load foo-bar before trying the loop, otherwise you'll
end up callnig terminal-init-foo without realizing that there's
a foo-bar.el.

> Doing it the (1) way would DTRT for the multi-tty branch, it would
> avoid loading the terminal file iff the corresponding terminal-init-
> function is defined, which would happen after connecting the first
> time from a terminal type.

I don't think it matters too much whether the file is reloaded many times.
If that's really a problem, we can check load-history, or use (require
'term/foo).


        Stefan

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

end of thread, other threads:[~2005-09-12 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-29 20:04 New $TERM init code Stefan Monnier
2005-07-29 23:56 ` Dan Nicolaescu
2005-09-12 15:51 ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.