Changeset - cecf5c408045
[Not reviewed]
0 1 0
Sergey Pashinin - 11 years ago 2014-07-26 17:13:59
sergey@pashinin.com
Changed minibuffer message
1 file changed with 1 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/workgroups-utils-basic.el
Show inline comments
 
@@ -584,92 +584,90 @@ ARGS are `read-from-minibuffer's args, after PROMPT."
 
      obj)))
 

	
 
(defvar wg-readable-types
 
  '(integer float cons symbol vector string char-table bool-vector)
 
  "List of types with readable printed representations.")
 

	
 
(defun wg-is-readable-p (obj)
 
  "Return non-nil if OBJ's printed representation is readable."
 
  (memq (type-of obj) wg-readable-types))
 

	
 
(defun wg-take-until-unreadable (list)
 
  "Return a new list of elements of LIST up to the first unreadable element."
 
  (wg-take-until-fail 'wg-is-readable-p list))
 

	
 
(defun wg-add-face (facekey string)
 
  "Return a copy of STRING fontified according to FACEKEY.
 
FACEKEY must be a key in `wg-face-abbrevs'."
 
  (let ((face (wg-aget wg-face-abbrevs facekey))
 
        (string  (copy-sequence string)))
 
    (unless face (error "No face with key %s" facekey))
 
    (if (not wg-use-faces) string
 
      (put-text-property 0 (length string) 'face face string)
 
      string)))
 

	
 
(defmacro wg-fontify (&rest specs)
 
  "A small fontification DSL.
 
The results of all SPECS are `concat'd together.
 
If a spec is a cons with a keyword car, apply `wg-add-face' to it.
 
Other conses get evaluated, and should produce a strings.
 
If a spec is a string it is used unmodified.
 
Anything else is formatted with %s to produce a string."
 
  (declare (indent defun))
 
  `(concat
 
    ,@(wg-docar (spec specs)
 
        (cond ((and (consp spec)
 
                    (keywordp (car spec)))
 
               `(wg-add-face ,@spec))
 
              ;;((listp spec) (cdr (eval spec)))
 
              ;;((listp spec)
 
              ;; ;;(prin1-to-string (nth 1 (eval spec)))
 
              ;; )
 
              ((consp spec) spec)
 
              ((stringp spec) spec)
 
              (t `(format "%s" ,spec))))))
 

	
 
(defun wg-barf-on-active-minibuffer ()
 
  "Throw an error when the minibuffer is active."
 
  (when (wg-minibuffer-active-p)
 
    (error "Workgroup operations aren't permitted while the \
 
minibuffer is active")))
 
    (error "Exit minibuffer to use workgroups functions!")))
 

	
 
(defmacro wg-set-parameter (place parameter value)
 
  "Set PARAMETER to VALUE at PLACE.
 
This needs to be a macro to allow specification of a setf'able place."
 
  (wg-with-gensyms (p v)
 
    `(let ((,p ,parameter) (,v ,value))
 
       (wg-pickelable-or-error ,p)
 
       (wg-pickelable-or-error ,v)
 
       (setf ,place (wg-aput ,place ,p ,v))
 
       ,v)))
 

	
 

	
 

	
 
;;; uid utils
 

	
 
(defun wg-time-to-b36 (&optional time)
 
  "Convert `current-time' into a b36 string."
 
  (apply 'concat (wg-docar (time (or time (current-time)))
 
                   (wg-int-to-b36 time 4))))
 

	
 
(defun wg-b36-to-time (b36)
 
  "Parse the time from UID."
 
  (cl-loop for i from 0 to 8 by 4
 
           collect (wg-b36-to-int (cl-subseq b36 i (+ i 4)))))
 

	
 

	
 
(defalias 'wg-uid-to-time 'wg-b36-to-time)
 

	
 
(defun wg-generate-uid (&optional prefix)
 
  "Return a new uid, optionally prefixed by PREFIX."
 
  (concat prefix
 
          (wg-time-to-b36)
 
          "-"
 
          (wg-int-to-b36 string-chars-consed)))
 

	
 
(defun wg-uid-to-seconds (uid)
 
  "Return the `float-time' parsed from UID with `wg-uid-to-time'."
 
  (float-time (wg-uid-to-time uid)))
 

	
 

	
 
(provide 'workgroups-utils-basic)
 
;;; workgroups-utils-basic.el ends here
0 comments (0 inline, 0 general)