Various changes.
[elisp.git] / emacs.el
index a2278be..64500c7 100644 (file)
--- a/emacs.el
+++ b/emacs.el
@@ -660,7 +660,7 @@ occurrences "
 ;; Printing
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(require 'ps-print)
+(load "ps-print")
 
 (setq ps-print-color-p nil
       ;; ps-paper-type 'letter
@@ -773,19 +773,23 @@ printer."
     (insert-file-contents-literally file)
     (buffer-substring (point-at-bol) (point-at-eol))))
 
-(defun ff/battery-percent ()
-  (/ (* 100 (string-to-number (ff/file-first-line (concat ff/battery-dir "/charge_now"))))
-     (string-to-number (ff/file-first-line (concat ff/battery-dir "/charge_full")))))
+(defun ff/battery-percent (prefix)
+  (condition-case nil
+      (/ (* 100 (string-to-number (ff/file-first-line (format "%s/%s_now" ff/battery-dir prefix))))
+         (string-to-number (ff/file-first-line (format "%s/%s_full"  ff/battery-dir prefix))))
+    (error -1))
+    )
 
 (defun ff/laptop-info-string () (interactive)
   (condition-case nil
       (concat
 
        ;; The temperature
+
        (let ((temp (/ (string-to-number (ff/file-first-line ff/temperature-file)) 1000)))
          (if (> temp 50)
              (concat
-              (let ((s (format "%dC" temp)))
+              (let ((s (format "%dC " temp)))
                 (if (> temp 65) (propertize s 'face
                                             'font-lock-warning-face)
                   s))
@@ -793,17 +797,24 @@ printer."
            )
          )
 
-       " "
-
        ;; The battery
 
        (let ((battery-status (ff/file-first-line (concat ff/battery-dir "/status"))))
 
          (cond
           ((string= battery-status "Full") "L")
-          ((string= battery-status "Charging") (format "L%d%%" (ff/battery-percent)))
-          ((string= battery-status "Discharging") (format "B%d%%"  (ff/battery-percent)))
-          (t "?")))
+
+          ((string= battery-status "Charging")
+           (format "L%d%%" (max (ff/battery-percent "charge")
+                                (ff/battery-percent "energy"))))
+
+          ((string= battery-status "Discharging")
+           (format "B%d%%"  (max (ff/battery-percent "charge")
+                                 (ff/battery-percent "energy"))))
+
+          (t battery-status)
+
+          ))
 
        )
 
@@ -1028,7 +1039,7 @@ of commands in `ff/default-bash-commands' is used for auto-completion"
  vc-follow-symlinks t
  )
 
-(when (require 'vc-git nil t)
+(when (load "vc-git" nil t)
   (add-to-list 'vc-handled-backends 'GIT))
 
 ;; alarm-vc.el is one of my own scripts, check my web page
@@ -1063,7 +1074,7 @@ of commands in `ff/default-bash-commands' is used for auto-completion"
 ;; Cool stuff to navigate in emacs-lisp sources
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(require 'find-func)
+(load "find-func")
 
 (defun ff/goto-function-definition (&optional goback)
   "Go directly to the definition of the function at point. With
@@ -2009,7 +2020,7 @@ This may be a useful alternative binding for \\[delete-other-windows]
 ;; Keymaping
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(require 'info nil t)
+(load "info" nil t)
 
 (define-key global-map [(shift iso-lefttab)] 'ispell-complete-word)
 ;; shift-tab going backward is kind of standard
@@ -2205,7 +2216,7 @@ next one. With universal argument, kill all killable buffers."
 ;; exclusively with my selector.el
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(require 'recentf)
+(load "recentf")
 
 (setq recentf-exclude
       (append recentf-exclude
@@ -2281,7 +2292,7 @@ next one. With universal argument, kill all killable buffers."
 ;; selector.el is one of my own scripts, check my web page
 
 (when (ff/load-or-alert "selector" t)
-  (define-key global-map [(shift return)] 'selector/quick-move-in-buffer)
+  ;; (define-key global-map [(shift return)] 'selector/quick-move-in-buffer)
   (define-key global-map [(control x) (control b)] 'selector/switch-buffer)
 
   (defun ff/visit-debpkg-file (&optional regexp)