Skip to content

Commit

Permalink
Clean: Minor doc/comment/other improvements to hy-mode.el
Browse files Browse the repository at this point in the history
  • Loading branch information
ekaschalk committed Jun 6, 2019
1 parent e319d2f commit c778457
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 34 deletions.
2 changes: 2 additions & 0 deletions VERSION.org
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
This file is deprecated ATM and might be restarted upon the jedhy release.

* Version 1.0.3 - in progress
** Eldoc supported
** Autocompletion (Company) supported
Expand Down
9 changes: 6 additions & 3 deletions hy-jedhy.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
(require 'hy-shell)

;;; Configuration
;;;; Configured

(defvar hy-jedhy--enable? t
"Should an internal process startup for use by ide components?")

;;;; Managed

(defvar-local hy-jedhy--running? nil
Expand Down Expand Up @@ -304,9 +309,7 @@ shift-K keybinding that executes `spacemacs/evil-smart-doc-lookup'."
(interactive)

(hy-shell--with-internal
;; TODO This needs need to be moved to `hy-jedhy.el'
(when (hy-jedhy--startup)
(hy-shell--notify-process-success-internal))))
(hy-jedhy--startup)))

;;; Provide:

Expand Down
44 changes: 20 additions & 24 deletions hy-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
;; (http://hylang.org), the lisp embedded in Python.

;; Syntax highlighting and related can be found in `hy-font-lock.el'
;; REPL support and IDE components can be found in `hy-shell.el'
;; REPL support can be found in `hy-shell.el'
;; IDE components support can be found in `hy-jedhy.el'
;; Common utilities and requires can be found in `hy-base.el'
;; Testing utilities for the test/ folder can be found in `hy-test.el'

Expand Down Expand Up @@ -86,26 +87,23 @@ Examples:

(defconst hy-mode-syntax-table
(let ((table (copy-syntax-table lisp-mode-syntax-table)))
;; List-likes
(modify-syntax-entry ?\{ "(}" table)
(modify-syntax-entry ?\} "){" table)
(modify-syntax-entry ?\[ "(]" table)
(modify-syntax-entry ?\] ")[" table)

;; Quote characters are prefixes
;; Quote Characters
(modify-syntax-entry ?\~ "'" table)
(modify-syntax-entry ?\@ "'" table)

;; "," is a symbol in Hy, namely the tuple constructor
;; Symbol Constituents
(modify-syntax-entry ?\, "_" table)

;; "|" is a symbol in hy, naming the or operator
(modify-syntax-entry ?\| "_" table)

;; "#" is a tag macro, we include # in the symbol
(modify-syntax-entry ?\# "_" table)

table)
"Hy mode's syntax table.")
"The `hy-mode' syntax table.")

(defconst inferior-hy-mode-syntax-table (copy-syntax-table hy-mode-syntax-table)
"`inferior-hy-mode' inherits `hy-mode-syntax-table'.")
Expand Down Expand Up @@ -186,7 +184,7 @@ commands."

;;;; Spec Finding

(defun hy-indent--syntax->spec (syntax)
(defun hy-indent--syntax->indent-spec (syntax)
"Get int for special indentation for SYNTAX state or nil for normal indent."
(-when-let (sym (and (hy--prior-sexp? syntax)
(thing-at-point 'symbol)))
Expand All @@ -202,21 +200,13 @@ commands."
(cond ((-contains? '(?\[ ?\{) (char-before))
(current-column))

((hy-indent--syntax->spec syntax)
((hy-indent--syntax->indent-spec syntax)
(1+ (current-column)))

(t (hy-indent--normal calculate-lisp-indent-last-sexp))))

;;; Misc Commands

;;;###autoload
(defun hy-insert-pdb ()
"Import and set pdb trace at point."
(interactive)
(insert "(do (import pdb) (pdb.set-trace))"))

;;; hy-mode
;;;; Setup - Core
;;; Setup
;;;; Core

(defun hy-mode--setup-font-lock ()
(setq-local font-lock-multiline t)
Expand Down Expand Up @@ -252,10 +242,10 @@ commands."

(defun hy-mode--setup-jedhy ()
;; (run-jedhy)
;; (add-hook 'pyvenv-post-activate-hooks 'run-jedhy nil t)
;; (add-hook 'pyvenv-post-activate-hooks #'run-jedhy nil 'local)
)

;;;; Setup - Support
;;;; Support

(defun hy-mode--support-eldoc ()
;; (make-local-variable #'eldoc-documentation-function)
Expand All @@ -274,7 +264,7 @@ commands."
(when (fboundp #'sp-local-pair)
(sp-local-pair '(hy-mode inferior-hy-mode) "`" "`" :actions nil)))

;;;; Mode Declaration
;;; hy-mode

(add-to-list 'auto-mode-alist '("\\.hy\\'" . hy-mode))
(add-to-list 'interpreter-mode-alist '("hy" . hy-mode))
Expand All @@ -287,7 +277,7 @@ commands."

(hy-mode--support-smartparens)

(when hy-shell--startup-internal-process?
(when hy-jedhy--enable?
(hy-mode--setup-jedhy)

(hy-mode--support-eldoc)
Expand All @@ -307,6 +297,12 @@ commands."

;;;; Misc

;;;###autoload
(defun hy-insert-pdb ()
"Import and set pdb trace at point."
(interactive)
(insert "(do (import pdb) (pdb.set-trace))"))

(define-key hy-mode-map (kbd "C-c C-t") #'hy-insert-pdb)

;;; Provide:
Expand Down
7 changes: 0 additions & 7 deletions hy-shell.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
(defvar hy-shell--interpreter-args '("--spy")
"Default argument list to pass to the Hy interpreter.")

(defvar hy-shell--startup-internal-process? t
"Should an internal process startup for use by ide components?")

(defvar hy-shell--enable-font-lock? t
"Whether the shell should font-lock repl prompt input.")

Expand Down Expand Up @@ -286,10 +283,6 @@ Expected to be called within a Hy interpreter process buffer."
(prog1 nil
(message "Hy executable not found. Install or activate a env with Hy.")))))

(defun hy-shell--notify-process-success-internal ()
(when hy-shell--notify?
(message "Internal Hy shell process successfully started.")))

;;; inferior-hy-mode
;;;; Colorings

Expand Down

0 comments on commit c778457

Please sign in to comment.