 
 ;; インストールされていないパッケージを require した時に、
 ;; 自動でインストールしたあとに require してくれる
-(defun kui/package-require (feature &optional filename packagename noerror)
-  "If PACKAGENAME(or FEATURE) was installed, execute `require' as:
-
-	(require FEATURE &optional FILENAME NOERROR)
-
-If PACKAGENAME(or FEATURE) not installed, execute `package-install' with
-PACKAGENAME(or FEATURE) and then execute `require'.
-If NOERROR is non-nil, then return nil if PACKAGENAME(or FEATURE) is not
-available package."
-  (condition-case err
-      (let ((pname (or packagename feature)))
-        (message "kui/package-require: %s, %s, %s, %s"
-                 feature filename packagename noerror)
-        (unless (package-installed-p pname) (package-install pname))
-        (require feature filename noerror))
-    (error (if noerror nil (error (cadr err))))))
+(put 'kui/package-require 'lisp-indent-function 1)
+(defun kui/package-require (feature &rest args)
+  (let* ((opts (kui/pop-as-assoc '(:file :package :throwerror) args))
+         (fl (cdr (assoc :file opts)))
+         (pkg (or (cdr (assoc :package opts)) feature))
+         (err (cdr (assoc :throwerror opts))))
+    (message "%s: feature=%s, file=%s, pacakge=%s, throwerror=%s"
+             "kui/package-require" feature fl pkg err)
+    (condition-case e
+        (let ()
+          (unless (package-installed-p pkg) (package-install pkg))
+          (require feature fl))
+      (error (if err (error (cadr e))
+               (message "Error on %s: %s"
+                        "kui/package-require" (cadr e))
+               nil)))))
 
 (put 'with-pkg 'lisp-indent-function 1)
 (defmacro with-pkg (feature &rest args)


  (guide-key-mode 1))

(when (and (kui/package-require 'flycheck nil nil t)
           (kui/package-require 'flycheck-pos-tip nil nil t))
  (custom-set-variables
      '(flycheck-display-errors-function #'flycheck-pos-tip-error-messages)))

;; company-mode
(when (kui/package-require 'company nil nil t)

  (setq company-global-modes nil
        ;; 自動補完を有効

  )

;; direx
(when (and (kui/package-require 'direx)
           (featurep 'popwin))
  (push '(direx:direx-mode :position :left :width 40 :dedicated t)
        popwin:special-display-config)

