[PATCH] Making smalltalk-mode.el available on Emacs package archives

Wilfred Hughes <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.gnu.general
Message-ID <CAFXAjY5p9zZ1SvYC1=dTU7tYT1Pw-8ZWHs4a_=01W=OqR-SNaw@mail.gmail.com>
Hi

There are various package archives available for distributing Emacs
packages, but
smalltalk-mode.el is not currently available on any of them.

The main issue is that smalltalk-mode.el does not have a valid package header or
footer. My patch below fixes this, and ensures the file can be used standalone.

I've also fixed some byte-compiler warnings.

You can see my patch as commits here:
https://github.com/Wilfred/gnu-smalltalk/compare/master...refactor_emacs_mode?expand=1

Thanks
Wilfred

Changes follow:

diff --git a/smalltalk-mode-init.el.in b/smalltalk-mode-init.el.in
index 0fc6321b..a2dbef9d 100644
--- a/smalltalk-mode-init.el.in
+++ b/smalltalk-mode-init.el.in
@@ -11,12 +11,9 @@
              (throw 'archive-mode (cdr mode-assoc))))))
       auto-mode-alist)

-(push '("\\.st\\'" . smalltalk-mode) auto-mode-alist)
-
 (if (boundp 'inhibit-local-variables-regexps)
     (push "\\.star\\'" inhibit-local-variables-regexps)
     (push "\\.star\\'" inhibit-first-line-modes-regexp))

-(autoload 'smalltalk-mode "@lispdir@/smalltalk-mode.elc" "" t)
 @WITH_EMACS_COMINT_TRUE@(autoload 'gst "@lispdir@/gst-mode.elc" "" t)

diff --git a/smalltalk-mode.el b/smalltalk-mode.el
index 14c74972..7f1f810c 100644
--- a/smalltalk-mode.el
+++ b/smalltalk-mode.el
@@ -1,3 +1,7 @@
+;;; smalltalk-mode.el --- Major mode for the Smalltalk programming language
+
+;;; Commentary:
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
 ;;; Copyright 1988-92, 1994-95, 1999, 2000, 2003, 2007, 2008, 2009
@@ -153,7 +157,7 @@
    '("#[A-z][A-z0-9_]*" . font-lock-constant-face)
    '("\\<[A-z][A-z0-9_]*:" . font-lock-function-name-face)
    (cons smalltalk-binsel 'font-lock-function-name-face)
-;   '("\\^" . font-lock-keyword-face)
+   '("\\^" . font-lock-keyword-face)
    '("\\$." . font-lock-string-face) ;; Chars
    '("\\<[A-Z]\\sw*\\>" . font-lock-type-face))
   "Basic Smalltalk keywords font-locking")
@@ -178,6 +182,7 @@

 ;; ---[ Interactive functions ]---------------------------------------

+;;;###autoload
 (defun smalltalk-mode ()
   "Major mode for editing Smalltalk code.

@@ -226,6 +231,9 @@ Commands:
   ;; Run hooks, must be last
   (run-hooks 'smalltalk-mode-hook))

+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.st\\'" . #'smalltalk-mode))
+
 (defun smalltalk-tab ()
   (interactive)
   (let (col)
@@ -417,7 +425,7 @@ expressions."

 (defun smalltalk-maybe-insert-spacing-line (n)
   (if (not (save-excursion
-         (previous-line n)
+         (forward-line (- n))
          (looking-at "^[ \t]*$")))
       (insert "\n")))

@@ -613,7 +621,7 @@ expressions."
     (and (= (preceding-char) ?|)
          (progn
            (backward-char 1)
-           (while (and (not (bobp)) (looking-back "[ \t\na-zA-Z]"))
+           (while (and (not (bobp)) (looking-back "[ \t\na-zA-Z]" nil))
          (skip-chars-backward " \t\n")
          (skip-chars-backward "a-zA-Z"))
            (if (= (preceding-char) ?|)
@@ -1026,22 +1034,23 @@ Whitespace is defined as spaces, tabs, and comments."
     (progn (setq curr-hit-point new-hit-point)
            (setq curr-hit new-hit)))
     (cons curr-hit curr-hit-point)))
-
+
+(defun smalltalk-update-hit-point (current search)
+  (save-excursion
+    (let ((new-hit-point (funcall search)))
+      (if (and new-hit-point
+               (or (not current) (> new-hit-point current)))
+          new-hit-point
+        current))))
+
 (defun smalltalk-current-scope-point ()
-  (defun smalltalk-update-hit-point (current search)
-    (save-excursion
-      (let ((new-hit-point (funcall search)))
-    (if (and new-hit-point
-         (or (not current) (> new-hit-point current)))
-        new-hit-point
-      current))))
   (let ((curr-hit-point (smalltalk-current-class-point)))
     (setq curr-hit-point
       (smalltalk-update-hit-point curr-hit-point
-                      #'(lambda ()(search-backward-regexp "^[
\t]*Eval[ \t]+\\[" nil t))))
+                      (lambda () (search-backward-regexp "^[
\t]*Eval[ \t]+\\[" nil t))))
     (setq curr-hit-point
       (smalltalk-update-hit-point curr-hit-point
-                      #'(lambda ()(search-backward-regexp "^[
\t]*Namespace[ \t]+current:[ \t]+[A-Za-z0-9_.]+[ \t]+\\[" nil t))))
+                      (lambda () (search-backward-regexp "^[
\t]*Namespace[ \t]+current:[ \t]+[A-Za-z0-9_.]+[ \t]+\\[" nil t))))
     curr-hit-point))

 (defun smalltalk-current-class-point ()
@@ -1115,13 +1124,13 @@ Whitespace is defined as spaces, tabs, and comments."
       (error (goto-char prev-point)))))

 (defun smalltalk-goto-beginning-of-statement ()
-  (if (not (looking-back "[ \t\n]"))
+  (if (not (looking-back "[ \t\n]" nil nil))
       (smalltalk-safe-backward-sexp)))

 (defun smalltalk-has-sender ()
   (save-excursion
     (smalltalk-backward-whitespace)
-    (looking-back "[]})A-Za-z0-9']")))
+    (looking-back "[]})A-Za-z0-9']" nil)))

 (defun smalltalk-looking-at-binary-send ()
   (looking-at "[^]A-Za-z0-9:_(){}[;.\'\"]+[ \t\n]"))
@@ -1133,7 +1142,7 @@ Whitespace is defined as spaces, tabs, and comments."
   (looking-at "[A-Za-z][A-Za-z0-9_]*:"))

 (defun smalltalk-looking-back-keyword-send ()
-  (looking-back "[A-z][A-z0-9_]*:"))
+  (looking-back "[A-z][A-z0-9_]*:" nil))

 (defun smalltalk-find-end-of-keyword-send ()
   (save-excursion
@@ -1150,8 +1159,8 @@ Whitespace is defined as spaces, tabs, and comments."
     (let ((begin-of-defun (smalltalk-at-begin-of-defun)))
       (smalltalk-backward-whitespace)
       (if (or (if begin-of-defun
-          (looking-back "[].;]")
-        (looking-back "[.;]"))
+          (looking-back "[].;]" nil)
+        (looking-back "[.;]" nil))
           (= (smalltalk-previous-keyword) (point)))
       ""
     (progn
@@ -1169,7 +1178,7 @@ Whitespace is defined as spaces, tabs, and comments."

 (defun smalltalk-previous-keyword-1 ()
   (smalltalk-backward-whitespace)
-  (if (looking-back "[>[({.^]") ;; not really ok when > is sent in a
keyword arg
+  (if (looking-back "[>[({.^]" nil) ;; not really ok when > is sent
in a keyword arg
       nil
     (if (= (point) (save-excursion (smalltalk-safe-backward-sexp) (point)))
     nil
@@ -1200,3 +1209,4 @@ Whitespace is defined as spaces, tabs, and comments."

 (provide 'smalltalk-mode)

+;;; smalltalk-mode.el ends here
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.