[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117559: * emacs-lisp/smie.el (smie-config--guess-1)
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] trunk r117559: * emacs-lisp/smie.el (smie-config--guess-1): Split from smie-config--guess. |
Date: |
Mon, 21 Jul 2014 01:58:51 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117559
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sun 2014-07-20 21:58:43 -0400
message:
* emacs-lisp/smie.el (smie-config--guess-1): Split from smie-config--guess.
(smie-config--guess): Use it.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/emacs-lisp/smie.el smie.el-20100517192034-xap3ihmey43772vj-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-07-21 01:56:54 +0000
+++ b/lisp/ChangeLog 2014-07-21 01:58:43 +0000
@@ -1,5 +1,9 @@
2014-07-21 Stefan Monnier <address@hidden>
+ * emacs-lisp/smie.el (smie-config--guess-1): Split from
+ smie-config--guess.
+ (smie-config--guess): Use it.
+
* emacs-lisp/edebug.el: Use nadvice.
(edebug-original-read): Remove.
(edebug--read): Rename from edebug-read and add `orig' arg.
=== modified file 'lisp/emacs-lisp/smie.el'
--- a/lisp/emacs-lisp/smie.el 2014-06-20 21:10:40 +0000
+++ b/lisp/emacs-lisp/smie.el 2014-07-21 01:58:43 +0000
@@ -632,14 +632,14 @@
an open-paren, whereas a RIGHT-LEVEL of nil would correspond to something
like a close-paren.")
-(defvar smie-forward-token-function 'smie-default-forward-token
+(defvar smie-forward-token-function #'smie-default-forward-token
"Function to scan forward for the next token.
Called with no argument should return a token and move to its end.
If no token is found, return nil or the empty string.
It can return nil when bumping into a parenthesis, which lets SMIE
use syntax-tables to handle them in efficient C code.")
-(defvar smie-backward-token-function 'smie-default-backward-token
+(defvar smie-backward-token-function #'smie-default-backward-token
"Function to scan backward the previous token.
Same calling convention as `smie-forward-token-function' except
it should move backward to the beginning of the previous token.")
@@ -806,9 +806,9 @@
nil: we skipped over an identifier, matched parentheses, ..."
(smie-next-sexp
(indirect-function smie-backward-token-function)
- (indirect-function 'backward-sexp)
- (indirect-function 'smie-op-left)
- (indirect-function 'smie-op-right)
+ (indirect-function #'backward-sexp)
+ (indirect-function #'smie-op-left)
+ (indirect-function #'smie-op-right)
halfsexp))
(defun smie-forward-sexp (&optional halfsexp)
@@ -827,9 +827,9 @@
nil: we skipped over an identifier, matched parentheses, ..."
(smie-next-sexp
(indirect-function smie-forward-token-function)
- (indirect-function 'forward-sexp)
- (indirect-function 'smie-op-right)
- (indirect-function 'smie-op-left)
+ (indirect-function #'forward-sexp)
+ (indirect-function #'smie-op-right)
+ (indirect-function #'smie-op-left)
halfsexp))
;;; Miscellaneous commands using the precedence parser.
@@ -1121,7 +1121,7 @@
:type 'integer
:group 'smie)
-(defvar smie-rules-function 'ignore
+(defvar smie-rules-function #'ignore
"Function providing the indentation rules.
It takes two arguments METHOD and ARG where the meaning of ARG
and the expected return value depends on METHOD.
@@ -2121,41 +2121,45 @@
otraces)
;; Finally, guess the indentation rules.
- (let ((ssigs nil)
- (rules nil))
- ;; Sort the sigs by frequency of occurrence.
- (maphash (lambda (sig sig-data) (push (cons sig sig-data) ssigs)) sigs)
- (setq ssigs (sort ssigs (lambda (sd1 sd2) (> (cadr sd1) (cadr sd2)))))
- (while ssigs
- (pcase-let ((`(,sig ,total ,off-alist ,cotraces) (pop ssigs)))
- (cl-assert (= total (apply #'+ (mapcar #'cdr off-alist))))
- (let* ((sorted-off-alist
- (sort off-alist (lambda (x y) (> (cdr x) (cdr y)))))
- (offset (caar sorted-off-alist)))
- (if (zerop offset)
- ;; Nothing to do with this sig; indentation is
- ;; correct already.
- nil
- (push (cons (+ offset (nth 2 sig)) sig) rules)
- ;; Adjust the rest of the data.
- (pcase-dolist ((and cotrace `(,count ,toffset . ,trace))
- cotraces)
- (setf (nth 1 cotrace) (- toffset offset))
- (dolist (sig trace)
- (let ((sig-data (cdr (assq sig ssigs))))
- (when sig-data
- (let* ((ooff-data (assq toffset (nth 1 sig-data)))
- (noffset (- toffset offset))
- (noff-data
- (or (assq noffset (nth 1 sig-data))
- (let ((off-data (cons noffset 0)))
- (push off-data (nth 1 sig-data))
- off-data))))
- (cl-assert (>= (cdr ooff-data) count))
- (cl-decf (cdr ooff-data) count)
- (cl-incf (cdr noff-data) count))))))))))
- (message "Guessing...done")
- rules))))
+ (prog1
+ (smie-config--guess-1 sigs)
+ (message "Guessing...done")))))
+
+(defun smie-config--guess-1 (sigs)
+ (let ((ssigs nil)
+ (rules nil))
+ ;; Sort the sigs by frequency of occurrence.
+ (maphash (lambda (sig sig-data) (push (cons sig sig-data) ssigs)) sigs)
+ (setq ssigs (sort ssigs (lambda (sd1 sd2) (> (cadr sd1) (cadr sd2)))))
+ (while ssigs
+ (pcase-let ((`(,sig ,total ,off-alist ,cotraces) (pop ssigs)))
+ (cl-assert (= total (apply #'+ (mapcar #'cdr off-alist))))
+ (let* ((sorted-off-alist
+ (sort off-alist (lambda (x y) (> (cdr x) (cdr y)))))
+ (offset (caar sorted-off-alist)))
+ (if (zerop offset)
+ ;; Nothing to do with this sig; indentation is
+ ;; correct already.
+ nil
+ (push (cons (+ offset (nth 2 sig)) sig) rules)
+ ;; Adjust the rest of the data.
+ (pcase-dolist ((and cotrace `(,count ,toffset . ,trace))
+ cotraces)
+ (setf (nth 1 cotrace) (- toffset offset))
+ (dolist (sig trace)
+ (let ((sig-data (cdr (assq sig ssigs))))
+ (when sig-data
+ (let* ((ooff-data (assq toffset (nth 1 sig-data)))
+ (noffset (- toffset offset))
+ (noff-data
+ (or (assq noffset (nth 1 sig-data))
+ (let ((off-data (cons noffset 0)))
+ (push off-data (nth 1 sig-data))
+ off-data))))
+ (cl-assert (>= (cdr ooff-data) count))
+ (cl-decf (cdr ooff-data) count)
+ (cl-incf (cdr noff-data) count))))))))))
+ rules))
(defun smie-config-guess ()
"Try and figure out this buffer's indentation settings.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117559: * emacs-lisp/smie.el (smie-config--guess-1): Split from smie-config--guess.,
Stefan Monnier <=