I've received some more feedback from Emacs people about the header
formatting on my patch, so here's an updated version. Would anyone be
able to apply this?

On 22 August 2017 at 00:00, Wilfred Hughes <m...@wilfred.me.uk> wrote:
>
> I've realised I made I mistake in the auto-mode-alist. I've attached
> the latest version of my patch.
>
> I already have FSF copyright papers signed, so this should be ready to
> merge. Let me know what you think.
>
> On 13 August 2017 at 11:59, Wilfred Hughes <m...@wilfred.me.uk> wrote:
> > 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
diff --git c/smalltalk-mode-init.el.in w/smalltalk-mode-init.el.in
index 0fc6321b..a2dbef9d 100644
--- c/smalltalk-mode-init.el.in
+++ w/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 c/smalltalk-mode.el w/smalltalk-mode.el
index 14c74972..d8a1d02a 100644
--- c/smalltalk-mode.el
+++ w/smalltalk-mode.el
@@ -1,30 +1,31 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;
-;;; Copyright 1988-92, 1994-95, 1999, 2000, 2003, 2007, 2008, 2009
-;;; Free Software Foundation, Inc.
-;;; Written by Steve Byrne.
-;;;
-;;; This file is part of GNU Smalltalk.
-;;;
-;;; GNU Smalltalk is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by the Free
-;;; Software Foundation; either version 2, or (at your option) any later 
-;;; version.
-;;;
-;;; GNU Smalltalk is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-;;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-;;; for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License along
-;;; with GNU Smalltalk; see the file COPYING.  If not, write to the Free
-;;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 
02110-1301, USA.
-;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;;; Incorporates Frank Caggiano's changes for Emacs 19.
-;;; Updates and changes for Emacs 20 and 21 by David Forster
+;;; smalltalk-mode.el --- Major mode for the Smalltalk programming language
 
+;; Copyright 1988-92, 1994-95, 1999, 2000, 2003, 2007, 2008, 2009
+;; Free Software Foundation, Inc.
+;; Written by Steve Byrne.
+
+;; This file is part of GNU Smalltalk.
+
+;; GNU Smalltalk is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by the Free
+;; Software Foundation; either version 2, or (at your option) any later
+;; version.
+
+;; GNU Smalltalk is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+;; for more details.
+
+;; You should have received a copy of the GNU General Public License along
+;; with GNU Smalltalk; see the file COPYING.  If not, write to the Free
+;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 
02110-1301, USA.
+
+;;; Commentary:
+
+;; Incorporates Frank Caggiano's changes for Emacs 19.
+;; Updates and changes for Emacs 20 and 21 by David Forster
+
+;;; Code:
 
 ;; ===[ Variables and constants ]=====================================
 
@@ -153,7 +154,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 +179,7 @@
 
 ;; ---[ Interactive functions ]---------------------------------------
 
+;;;###autoload
 (defun smalltalk-mode ()
   "Major mode for editing Smalltalk code.
 
@@ -226,6 +228,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 +422,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 +618,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 +1031,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 +1121,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 +1139,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 +1156,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 +1175,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 +1206,4 @@ Whitespace is defined as spaces, tabs, and comments."
 
 (provide 'smalltalk-mode)
 
+;;; smalltalk-mode.el ends here
_______________________________________________
help-smalltalk mailing list
help-smalltalk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to