 (require 'json)
 (require 'ring)
 (require 'etags)
-(require 'flymake)
-(require 'eldoc)
+;; (require 'flymake)
+;; (require 'eldoc)
 (require 'pos-tip nil t)
-(require 'log4e)
-(require 'yaxception)
+;; (require 'log4e)
+;; (require 'yaxception)
 (require 'thingatpt)
+(require 'button-lock)
+
+
 
 (cl-defstruct position file row col)
 

     (if (or (<= p low) (liquid-is-split ch)) 
	 p 
         (liquid-id-start-pos low (- p 1)))))

(defun column-number-at-pos (pos)
  "Find the column of position pos"

	 (str (get-string-from-file filePath)))
    (json-read-from-string str)))

;; Global variable holding the annotations
(defvar liquid-annot-table)

;; -----------------------------------------------------------------------------------------------
;; API for getting annots -- alist
;; -----------------------------------------------------------------------------------------------
;; (setq liquid-annot-table (get-json-from-file "/Users/rjhala/tmp/.liquid/flycheck_Foo.hs.json"))
;; 
;; (defun liquid-annot (table row col)
;;   "Get annotation from table from identifier at row, col"
;;   (let* ((r    (format "%d" row))
;; 	 (c    (format "%d" col))
;; 	 (tys  (assoc "types" table))
;; 	 (ro   (assoc r tys)))
;;     (cdr (assoc "ann" (assoc c ro)))))
;; -----------------------------------------------------------------------------------------------

;; -----------------------------------------------------------------------------------------------
;; API for getting annots -- hash-table 
;; -----------------------------------------------------------------------------------------------

(setq liquid-annot-table 
      (let ((json-object-type 'hash-table))
	(get-json-from-file "/Users/rjhala/tmp/.liquid/flycheck_Foo.hs.json")))

(defun gethash-nil (key table) 
  (if table 
      (gethash key table nil)
      nil))

(defun liquid-annot-get (file row col)
  "Get annotation for identifier at row, col in file"
  (let* ((table (gethash-nil file liquid-annot-table))
	 (r     (format "%d" row))
	 (c     (format "%d" col))
	 (tys   (gethash-nil "types" table))
	 (ro    (gethash-nil r tys)))
    (gethash-nil "ann" (gethash-nil c ro))))

;; -- Display --------------------------------------------------------------

;; If you want the separate balloon-popup
(defun liquid-tip-popup (text)
  "Display text in a window popup"
  (if (and (functionp 'ac-quick-help-use-pos-tip-p)
           (ac-quick-help-use-pos-tip-p))
      (pos-tip-show text 'popup-tip-face nil nil 300 popup-tip-max-width)
    (popup-tip text)))

;; If you just want the ascii-popup
;; (defun liquid-tip-popup (text)
;;  "Display text in ascii popup"
;;   (popup-tip text))


;; -- Compute range ---------------------------------------------------------

(defvar liquid-id-regexp 
  (rx (one-or-more (not (in " \n\t()[]{}")))))

(defun liquid-splitters () 
  '( ?\s  ?\t ?\n ?\( ?\) ?\[ ?\] ))
