Skip to content

More precise syntax table entries. #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 1, 2015

Conversation

ikirill
Copy link
Contributor

@ikirill ikirill commented Jan 1, 2015

The list of characters was generated procedurally based on
get-char-code-property, corresponding to ghc's Lexeme.hs's
implementation of which categories are valid.

(defun compress-list (list)
  (when list
    (let (sofar start end)
      (setq start (pop list)
            end start)
      (dolist (c list)
        (if (= c (1+ end))
            (incf end)
          (push (cons start end) sofar)
          (setq start c
                end c)))
      (push (cons start end) sofar)
      (setq sofar (mapcar (lambda (x) (if (= (car x) (cdr x)) (car x) x)) sofar)
            sofar (nreverse sofar))
      sofar)))


(let (haskell-sym-list haskell-var-list)
  (dolist (block unicode-fonts-blocks)
    (let (varid
          symid
          (varok '(Lu Lt Lo Ll Nd No))
          (symok '(Pc Pd Po Sm Sc Sk So)))
      (dolist (char (number-sequence (nth 1 block) (nth 2 block)))
        (let ((cat (get-char-code-property char 'general-category)))
          (cond
           ((< char #x80) nil)
           ((memq cat varok) (push char varid))
           ((memq cat symok) (push char symid)))))
      (setq varid (nreverse varid)
            symid (nreverse symid)
            haskell-sym-list (append haskell-sym-list (compress-list symid))
            haskell-var-list (append haskell-var-list (compress-list varid))
            )))
  ;; haskell-sym-list
  (setq haskell-sym-list (sort haskell-sym-list (lambda (a b) (< (or (car-safe a) a) (or (car-safe b) b)))))
  (setq haskell-var-list (sort haskell-var-list (lambda (a b) (< (or (car-safe a) a) (or (car-safe b) b)))))
  haskell-var-list
  )

The list of characters was generated procedurally based on
get-char-code-property, corresponding to ghc's Lexeme.hs's
implementation of which categories are valid.
@ikirill
Copy link
Contributor Author

ikirill commented Jan 1, 2015

@purcell It would make sense to split the lists of characters into a separate file, so that haskell-mode.el doesn't get polluted, but I'm not sure if project definition files need updating and what not.

Also, other emacs-lisp code might depend on syntax tables to walk along code, so it would help if things like \\s-w and \\s-_ in regexes were always precisely correct, which is why making the syntax table accurate is not pointless. But many of these characters are really uncommon.

@purcell
Copy link
Member

purcell commented Jan 1, 2015

Nice. I think this is fine inline for now, and I agree that it's good to make the syntax table as accurate as possible.

purcell added a commit that referenced this pull request Jan 1, 2015
More precise syntax table entries.
@purcell purcell merged commit 0db5efa into haskell:master Jan 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants