all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where appropriate.
@ 2013-10-31 12:40 Bozhidar Batsov
  2013-10-31 17:55 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Bozhidar Batsov @ 2013-10-31 12:40 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 175 bytes --]

Hi everyone,  

The attached patch simply replaces (set (make-local-variable …)…) with `setq-local’ where appropriate in ruby-mode.el.  

--  
Cheers,
Bozhidar


[-- Attachment #1.2: Type: text/html, Size: 464 bytes --]

[-- Attachment #2: 0001-lisp-progmodes-ruby-mode.el-Use-setq-local-where-app.patch --]
[-- Type: application/octet-stream, Size: 4096 bytes --]

From 05c45e2fad7abd9fa1214554ee8fed1e1ea53f9f Mon Sep 17 00:00:00 2001
From: Bozhidar Batsov <bozhidar@batsov.com>
Date: Thu, 31 Oct 2013 14:35:05 +0200
Subject: [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where
 appropriate.

---
 lisp/progmodes/ruby-mode.el | 52 ++++++++++++++++++---------------------------
 1 file changed, 21 insertions(+), 31 deletions(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 441f166..80edeb5 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -568,17 +568,17 @@ explicitly declared in magic comment."
       (smie-setup ruby-smie-grammar #'ruby-smie-rules
                   :forward-token  #'ruby-smie--forward-token
                   :backward-token #'ruby-smie--backward-token)
-    (set (make-local-variable 'indent-line-function) 'ruby-indent-line))
-  (set (make-local-variable 'require-final-newline) t)
-  (set (make-local-variable 'comment-start) "# ")
-  (set (make-local-variable 'comment-end) "")
-  (set (make-local-variable 'comment-column) ruby-comment-column)
-  (set (make-local-variable 'comment-start-skip) "#+ *")
-  (set (make-local-variable 'parse-sexp-ignore-comments) t)
-  (set (make-local-variable 'parse-sexp-lookup-properties) t)
-  (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter))
-  (set (make-local-variable 'paragraph-separate) paragraph-start)
-  (set (make-local-variable 'paragraph-ignore-fill-prefix) t))
+    (setq-local indent-line-function 'ruby-indent-line))
+  (setq-local require-final-newline t)
+  (setq-local comment-start "# ")
+  (setq-local comment-end "")
+  (setq-local comment-column ruby-comment-column)
+  (setq-local comment-start-skip "#+ *")
+  (setq-local parse-sexp-ignore-comments t)
+  (setq-local parse-sexp-lookup-properties t)
+  (setq-local paragraph-start (concat "$\\|" page-delimiter))
+  (setq-local paragraph-separate paragraph-start)
+  (setq-local paragraph-ignore-fill-prefix t))
 
 (defun ruby-mode-set-encoding ()
   "Insert a magic comment header with the proper encoding if necessary."
@@ -2072,32 +2072,22 @@ The variable `ruby-indent-level' controls the amount of indentation.
 \\{ruby-mode-map}"
   (ruby-mode-variables)
 
-  (set (make-local-variable 'imenu-create-index-function)
-       'ruby-imenu-create-index)
-  (set (make-local-variable 'add-log-current-defun-function)
-       'ruby-add-log-current-method)
-  (set (make-local-variable 'beginning-of-defun-function)
-       'ruby-beginning-of-defun)
-  (set (make-local-variable 'end-of-defun-function)
-       'ruby-end-of-defun)
+  (setq-local imenu-create-index-function 'ruby-imenu-create-index)
+  (setq-local add-log-current-defun-function 'ruby-add-log-current-method)
+  (setq-local beginning-of-defun-function 'ruby-beginning-of-defun)
+  (setq-local end-of-defun-function 'ruby-end-of-defun)
 
   (add-hook 'after-save-hook 'ruby-mode-set-encoding nil 'local)
 
-  (set (make-local-variable 'electric-indent-chars)
-       (append '(?\{ ?\}) electric-indent-chars))
+  (setq-local electric-indent-chars (append '(?\{ ?\}) electric-indent-chars))
 
-  (set (make-local-variable 'font-lock-defaults)
-       '((ruby-font-lock-keywords) nil nil))
-  (set (make-local-variable 'font-lock-keywords)
-       ruby-font-lock-keywords)
-  (set (make-local-variable 'font-lock-syntax-table)
-       ruby-font-lock-syntax-table)
+  (setq-local font-lock-defaults '((ruby-font-lock-keywords) nil nil))
+  (setq-local font-lock-keywords ruby-font-lock-keywords)
+  (setq-local font-lock-syntax-table ruby-font-lock-syntax-table)
 
   (if (eval-when-compile (fboundp 'syntax-propertize-rules))
-      (set (make-local-variable 'syntax-propertize-function)
-           #'ruby-syntax-propertize-function)
-    (set (make-local-variable 'font-lock-syntactic-keywords)
-         ruby-font-lock-syntactic-keywords)))
+      (setq-local syntax-propertize-function #'ruby-syntax-propertize-function)
+    (setq-local font-lock-syntactic-keywords ruby-font-lock-syntactic-keywords)))
 
 ;;; Invoke ruby-mode when appropriate
 
-- 
1.8.4


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

* Re: [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where appropriate.
  2013-10-31 12:40 [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where appropriate Bozhidar Batsov
@ 2013-10-31 17:55 ` Stefan Monnier
  2013-10-31 19:44   ` Bozhidar Batsov
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-10-31 17:55 UTC (permalink / raw)
  To: Bozhidar Batsov; +Cc: emacs-devel

> The attached patch simply replaces (set (make-local-variable …)…) with
> setq-local’ where appropriate in ruby-mode.el.

Is it OK to use such bleeding-edge constructs in ruby-mode.el, or is
there still some external version with which we should try to preserve
compatibility?

I meant, the code still tests (functionp 'syntax-ppss), so if we can
drop backward compatibility, there are probably more cleanups ahead.


        Stefan



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

* Re: [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where appropriate.
  2013-10-31 17:55 ` Stefan Monnier
@ 2013-10-31 19:44   ` Bozhidar Batsov
  2013-11-01  3:43     ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Bozhidar Batsov @ 2013-10-31 19:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

I think that we don't need to worry about compatibility with the other
version of the ruby-mode in Ruby's SVN repo, since just about nobody uses
it (except maybe some Emacs 23 users?).

ruby-mode suffers from a lot of legacy in it (compared to other built-in
modes) and would definitely benefit from a clean up. After all, simpler
code is always easier to improve, extend and debug.


On 31 October 2013 19:55, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> > The attached patch simply replaces (set (make-local-variable …)…) with
> > setq-local’ where appropriate in ruby-mode.el.
>
> Is it OK to use such bleeding-edge constructs in ruby-mode.el, or is
> there still some external version with which we should try to preserve
> compatibility?
>
> I meant, the code still tests (functionp 'syntax-ppss), so if we can
> drop backward compatibility, there are probably more cleanups ahead.
>
>
>         Stefan
>

[-- Attachment #2: Type: text/html, Size: 1396 bytes --]

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

* Re: [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where appropriate.
  2013-10-31 19:44   ` Bozhidar Batsov
@ 2013-11-01  3:43     ` Dmitry Gutov
  2013-11-01 12:26       ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2013-11-01  3:43 UTC (permalink / raw)
  To: Bozhidar Batsov; +Cc: Stefan Monnier, emacs-devel

Bozhidar Batsov <bozhidar@batsov.com> writes:

> I think that we don't need to worry about compatibility with the other version of the ruby-mode in
> Ruby's SVN repo, since just about nobody uses it (except maybe some Emacs 23 users?). 

I think more importantly, no one's trying to merge the code from the
trunk ruby-mode back to the Ruby repo (at least, in its entirety), or
use this package separately from the Emacs trunk.

> ruby-mode suffers from a lot of legacy in it (compared to other built-in modes) and would
> definitely benefit from a clean up. After all, simpler code is always easier to improve, extend
> and debug.

+1

I can't say it's too hard to understand, but the code will be easier to
understand for a new reader without the (fboundp
'syntax-propertize-rules) mess at the end.



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

* Re: [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where appropriate.
  2013-11-01  3:43     ` Dmitry Gutov
@ 2013-11-01 12:26       ` Stefan Monnier
  2013-11-02  0:23         ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-11-01 12:26 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Bozhidar Batsov, emacs-devel

> I think more importantly, no one's trying to merge the code from the
> trunk ruby-mode back to the Ruby repo (at least, in its entirety), or
> use this package separately from the Emacs trunk.

As long as Emacs's own ruby-mode.el is regularly kept up-to-date with
the external one, I'm OK with getting rid of the compatibility code.


        Stefan



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

* Re: [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where appropriate.
  2013-11-01 12:26       ` Stefan Monnier
@ 2013-11-02  0:23         ` Dmitry Gutov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2013-11-02  0:23 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Bozhidar Batsov, emacs-devel

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

> As long as Emacs's own ruby-mode.el is regularly kept up-to-date with
> the external one, I'm OK with getting rid of the compatibility code.

Cool. Compatibility code says bye.



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

end of thread, other threads:[~2013-11-02  0:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-31 12:40 [PATCH] * lisp/progmodes/ruby-mode.el: Use `setq-local' where appropriate Bozhidar Batsov
2013-10-31 17:55 ` Stefan Monnier
2013-10-31 19:44   ` Bozhidar Batsov
2013-11-01  3:43     ` Dmitry Gutov
2013-11-01 12:26       ` Stefan Monnier
2013-11-02  0:23         ` Dmitry Gutov

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.