Merged.

Pascal J. Bourguignon [2019-06-16 08:02]
Merged.
Filename
android-classes.el
freerdp-c-style.el
pjb-advices.el
pjb-banks.el
pjb-c.el
pjb-cl.el
pjb-emacs.el
pjb-erc.el
pjb-loader.el
pjb-math.el
pjb-objc-ide.el
pjb-searches.el
pjb-sources.el
pjb-xresources.el
pl1-keywords.lisp
diff --git a/android-classes.el b/android-classes.el
index b8bed19..add7e04 100644
--- a/android-classes.el
+++ b/android-classes.el
@@ -21,7 +21,7 @@
         (packages (mapcar (lambda (li)
                             (let* ((a (get-first-child-tagged li 'a))
                                    (href (attribute-value (get-attribute-named a 'href )))
-                                   (name (string-trim " \n\t" (first (element-children a)))))
+                                   (name (cl:string-trim " \n\t" (first (element-children a)))))
                               (make-android-package-info name href)))
                           lis))
         (table (get-first-child-tagged body 'table))
@@ -30,7 +30,7 @@
                            (let* ((linkcol (get-first-child-valued tr 'class "jd-linkcol"))
                                   (a (get-first-child-tagged linkcol 'a))
                                   (url  (attribute-value (get-attribute-named a 'href)))
-                                  (name (string-trim " \n\t" (first (element-children a))))
+                                  (name (cl:string-trim " \n\t" (first (element-children a))))
                                   (package (if (and (prefixp root url)
                                                     (suffixp ".html" url))
                                                (substitute (character ".") (character "/")
diff --git a/freerdp-c-style.el b/freerdp-c-style.el
new file mode 100644
index 0000000..893fbd4
--- /dev/null
+++ b/freerdp-c-style.el
@@ -0,0 +1,628 @@
+;;;; -*- mode:emacs-lisp;coding:utf-8 -*-
+;;;;**************************************************************************
+;;;;FILE:               pjb-c-style.el
+;;;;LANGUAGE:           emacs lisp
+;;;;SYSTEM:             POSIX
+;;;;USER-INTERFACE:     NONE
+;;;;DESCRIPTION
+;;;;
+;;;;    Defines my own C-style.
+;;;;
+;;;;AUTHORS
+;;;;    <PJB> Pascal Bourguignon <pbourguignon@dxo.com>
+;;;;MODIFICATIONS
+;;;;    2012-11-15 <PJB> Created.
+;;;;BUGS
+;;;;LEGAL
+;;;;    AGPL3
+;;;;
+;;;;    Copyright Pascal Bourguignon 2012 - 2012
+;;;;
+;;;;    This program is free software: you can redistribute it and/or modify
+;;;;    it under the terms of the GNU Affero General Public License as published by
+;;;;    the Free Software Foundation, either version 3 of the License, or
+;;;;    (at your option) any later version.
+;;;;
+;;;;    This program is distributed in the hope that it will be useful,
+;;;;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;;    GNU Affero General Public License for more details.
+;;;;
+;;;;    You should have received a copy of the GNU Affero General Public License
+;;;;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;;;**************************************************************************
+(require 'cl) ; always
+(require 'cc-mode)
+
+
+(setf auto-mode-alist (append '(("src/.*\\.h$" . objc-mode)
+                                ("\\.m$"  . objc-mode)
+                                ("\\.mm$" . objc-mode))
+                              auto-mode-alist))
+
+
+
+(c-add-style
+ "freerdp"
+ '((c-backslash-column             .  72)
+
+   (c-backslash-max-column         . 128)
+
+   (c-basic-offset                 . 8)  ; Amount of basic offset used by `+' and
+                                        ; `-' symbols in `c-offsets-alist'.
+
+   (c-block-comment-prefix         .  "")
+
+   (c-cleanup-list                 . (brace-else-brace
+                                      brace-elseif-brace
+                                      brace-catch-brace
+                                      list-close-comma
+                                      scope-operator))
+
+   (c-comment-only-line-offset     . (0 . 0))
+
+   ;; (c-comment-prefix-regexp)
+
+   (c-doc-comment-style            . javadoc)
+
+   (c-hanging-braces-alist
+    . (
+       ;; (statement-cont)
+       ;; (brace-list-intro)
+       (inexpr-class-open    . (before after))
+       (inexpr-class-close   . (before after))
+
+       (defun-open           . (before after))         ; Brace that opens a function definition.
+       (defun-close          . (before after))        ; Brace that closes a function definition.
+       (class-open           . (before after))  ; Brace that opens a class definition.
+       (class-close          . ())              ; Brace that closes a class definition.
+       (inline-open          . (before after))  ; Brace that opens an in-class inline method.
+       (inline-close         . (before after))        ; Brace that closes an in-class inline method.
+       (block-open           . ())              ; Statement block open brace.
+       (block-close          . c-snug-do-while) ; Statement block close brace.
+       (brace-list-open      . (before after))         ; Open brace of an enum or static array list.
+       (brace-list-close     . (before after))  ; Close brace of an enum or static array list.
+       (brace-entry-open     . (before after))  ; Subsequent lines in an enum or static array
+       (statement-case-open  . (before after))         ; The first line in a case block starting with brace.
+       (substatement-open    . (before after))         ; The brace that opens a substatement block.
+       (extern-lang-open     . (before after))         ; Brace that opens an "extern" block.
+       (extern-lang-close    . (before after))  ; Brace that closes an "extern" block.
+       (namespace-open       . (before after))
+       (namespace-close      . ())
+       (module-open          . (before after))
+       (module-close         . ())
+       (composition-open     . (before after))
+       (composition-close)   . ()))
+
+   (c-hanging-colons-alist         . ((case-label           . (after))
+                                      (label                . (after))
+                                      (access-label         . (after))
+                                      (member-init-intro    . ())
+                                      (inher-intro          . ())))
+
+   (c-hanging-semi&comma-criteria  . ())
+
+   ;; (c-indent-comment-alist)
+
+   (c-indent-comments-syntactically-p . nil)
+
+   (c-label-minimum-indentation       . 2)
+
+   (c-offsets-alist
+    . (
+
+       (string                . 0)
+       ;; Inside multi-line string.
+
+       (c                     . 0)
+       ;; Inside a multi-line C style block comment.
+
+       (defun-open            . 0)
+       ;; Brace that opens a function definition.
+
+       (defun-close           . 0)
+       ;; Brace that closes a function definition.
+
+       (defun-block-intro     . +)
+       ;; The first line in a top-level defun.
+
+       (class-open            . 0)
+       ;; Brace that opens a class definition.
+
+       (class-close           . 0)
+       ;; Brace that closes a class definition.
+
+       (inline-open           . 0)
+       ;; Brace that opens an in-class inline method.
+
+       (inline-close          . 0)
+       ;; Brace that closes an in-class inline method.
+
+       (func-decl-cont        . +)
+       ;; The region between a function definition's
+       ;; argument list and the function opening brace
+       ;; (excluding K&R argument declarations).  In C, you
+       ;; cannot put anything but whitespace and comments
+       ;; between them; in C++ and Java, throws declarations
+       ;; and other things can appear in this context.
+
+       (knr-argdecl-intro     . +)
+       ;; First line of a K&R C argument declaration.
+
+       (knr-argdecl           . +)
+       ;; Subsequent lines in a K&R C argument declaration.
+
+       (topmost-intro         . 0)
+       ;; The first line in a topmost construct definition.
+
+       (topmost-intro-cont    . (c-lineup-string-cont
+                                 0))
+       ;; Topmost definition continuation lines.
+
+       (member-init-intro     . +)
+       ;; First line in a member initialization list.
+
+       (member-init-cont      . ++)
+       ;; Subsequent member initialization list lines.
+
+       (inher-intro           . +)
+       ;; First line of a multiple inheritance list.
+
+       (inher-cont            . ++)
+       ;; Subsequent multiple inheritance lines.
+
+       (block-open            . 0)
+       ;; Statement block open brace.
+
+       (block-close           . 0)
+       ;; Statement block close brace.
+
+       (brace-list-open       . 0)
+       ;; Open brace of an enum or static array list.
+
+       (brace-list-close      . 0)
+       ;; Close brace of an enum or static array list.
+
+       (brace-list-intro      . +)
+       ;; First line in an enum or static array list.
+
+       (brace-list-entry      . 0)
+       ;; Subsequent lines in an enum or static array list.
+
+       (brace-entry-open      . 0)
+       ;; Subsequent lines in an enum or static array
+       ;; list that start with an open brace.
+
+       (statement             . (c-lineup-runin-statements
+                                 0))
+       ;; A C (or like) statement.
+
+       (statement-cont        . (c-lineup-string-cont
+                                 ++))
+       ;; A continuation of a C (or like) statement.
+
+       (statement-block-intro . +)
+       ;; The first line in a new statement block.
+
+       (statement-case-intro  . +)
+       ;; The first line in a case "block".
+
+       (statement-case-open   . +)
+       ;; The first line in a case block starting with brace.
+
+       (substatement          . +)
+       ;; The first line after an if/while/for/do/else.
+
+       (substatement-open     . 0)
+       ;; The brace that opens a substatement block.
+
+       (substatement-label    . /)
+       ;; Labelled line after an if/while/for/do/else.
+
+       (case-label            . +)
+       ;; A "case" or "default" label.
+
+       (access-label          . -)
+       ;; C++ private/protected/public access label.
+
+       (label                 . /)
+       ;; Any ordinary label.
+
+       (do-while-closure      . 0)
+       ;; The "while" that ends a do/while construct.
+
+       (else-clause           . 0)
+       ;; The "else" of an if/else construct.
+
+       (catch-clause          . 0)
+       ;; The "catch" or "finally" of a try/catch construct.
+
+       (comment-intro         . 0)
+       ;; A line containing only a comment introduction.
+
+       (arglist-intro         . (c-lineup-arglist-intro-after-paren
+                                 +))
+       ;; The first line in an argument list.
+
+       (arglist-cont          . (c-lineup-string-cont
+                                 ;; c-lineup-arglist-intro-after-paren
+                                 ;; ssssc-lineup-argcont
+                                 +))
+       ;; Subsequent argument list lines when no
+       ;; arguments follow on the same line as the
+       ;; arglist opening paren.
+
+       (arglist-cont-nonempty . (c-lineup-string-cont
+                                 ;; c-lineup-arglist-intro-after-paren
+                                 ;; c-lineup-argcont
+                                 +))
+       ;; Subsequent argument list lines when at
+       ;; least one argument follows on the same
+       ;; line as the arglist opening paren.
+
+       (arglist-close         . (c-lineup-argcont
+                                 c-lineup-arglist-intro-after-paren
+                                 -))
+       ;; The solo close paren of an argument list.
+
+       (stream-op             . (c-lineup-streamop +))
+       ;; Lines continuing a stream operator construct.
+
+       (inclass               . +)
+       ;; The construct is nested inside a class definition.
+       ;; Used together with e.g. `topmost-intro'.
+
+       (cpp-macro             . [0])
+       ;; The start of a C preprocessor macro definition.
+
+       (cpp-macro-cont        . [8])
+       ;; Inside a multi-line C preprocessor macro definition.
+
+       (friend                . 0)
+       ;; A C++ friend declaration.
+
+       (objc-method-intro     . 0)
+       ;; The first line of an Objective-C method definition.
+
+       (objc-method-args-cont . (c-lineup-ObjC-method-args-2
+                                 +))
+       ;; Lines continuing an Objective-C method definition.
+
+       (objc-method-call-cont . (c-lineup-ObjC-method-call-colons
+                                 c-lineup-ObjC-method-call
+                                 +))
+       ;; Lines continuing an Objective-C method call.
+
+       (extern-lang-open      . 0)
+       ;; Brace that opens an "extern" block.
+
+       (extern-lang-close     . 0)
+       ;; Brace that closes an "extern" block.
+
+       (inextern-lang         . +)
+       ;; Analogous to the `inclass' syntactic symbol,
+       ;; but used inside "extern" blocks.
+
+       (namespace-open        . 0)
+
+       (namespace-close       . 0)
+
+       (innamespace           . +)
+       ;; Similar to the three `extern-lang' symbols, but for
+       ;; C++ "namespace" blocks.
+
+       (module-open           . 0)
+
+       (module-close          . 0)
+
+       (inmodule              . +)
+       ;; Similar to the three `extern-lang' symbols, but for
+       ;; CORBA IDL "module" blocks.
+
+       (composition-open      . 0)
+
+       (composition-close     . 0)
+
+       (incomposition         . +)
+       ;; Similar to the three `extern-lang' symbols, but for
+       ;; CORBA CIDL "composition" blocks.
+
+       (template-args-cont    . (c-lineup-template-args +))
+       ;; C++ template argument list continuations.
+
+       (inlambda              . +)
+       ;; In the header or body of a lambda function.
+
+       (lambda-intro-cont     . ++)
+       ;; Continuation of the header of a lambda function.
+
+       (inexpr-statement      . +)
+       ;; The statement is inside an expression.
+
+       (inexpr-class          . +)
+       ;; The class is inside an expression.  Used e.g. for
+       ;; Java anonymous classes.
+       ))
+
+   ;; Only called when c-syntactic-indentation is non nil.
+   ;; (c-special-indent-hook . user-fun)
+   (c-label-minimum-indentation    . 8)
+
+   ;; other emacs variables:
+   ;; (c-comment-continuation-stars "" t)
+   ;; (c-echo-syntactic-information-p t)
+   ;; (c-hanging-comment-ender-p nil t)
+   ;; (c-hanging-comment-starter-p nil t)
+   ;; (c-macro-shrink-window-flag          . t)
+
+
+   (tab-width                      . 8)  ; the true one!
+
+   (c-indent-level                 . 8)  ; Indentation of C statements with
+                                        ; respect to containing block.
+
+   (c-brace-imaginary-offset       . 0)  ; Imagined indentation of a C open brace
+                                        ; that actually follows a statement.
+
+   (c-brace-offset                 . 0)  ; Extra indentation for braces, compared
+                                        ; with other text in same context.
+
+   (c-argdecl-indent               . 8)  ; Indentation level of declarations of
+                                        ; C function arguments.
+
+   (c-label-offset                 . -)  ; Offset of C label lines and case
+                                        ; statements relative to usual
+                                        ; indentation.
+
+   (c-continued-statement-offset   . 8)  ; Extra indent for lines not starting
+                                        ; new statements.
+
+   (c-continued-brace-offset       . 0)  ; Extra indent for substatements that
+                                        ; start with open-braces.
+
+
+   (c-auto-newline                . nil) ; Non-nil means automatically newline
+                                        ; before and after braces, and after
+                                        ; colons and semicolons, inserted in C
+                                        ; code. If you do not want a leading
+                                        ; newline before braces then use:
+                                        ; (define-key c-mode-map \"{\"
+                                        ;          'electric-c-semi)"
+
+   (c-tab-always-indent           . t)  ; Non-nil means TAB in C mode should
+                                        ; always reindent the current line,
+                                        ; regardless of where in the line point
+                                        ; is when the TAB command is used.
+   ))
+
+;; ,  -> remove previous spaces; add following space;
+;; (  -> remove previous spaces; insert one previous space;
+;; {  -> insert one previous newline; indent;
+;; }  -> insert one previous newline; indent; add one following newline; indent;
+;; =  -> if previous is [-+!<=>&|^*/]
+;;       then remove previous spaces; add following space;
+;;       else add following space;
+;; ^  -> add following space
+;; */ -> remove previous spaces; if previous is not other then insert one previous space; end; add following space;
+;; -+&| -> if previous is same
+;;         then remove previous spaces; add following space;
+;;         else add following space;
+
+(defun spacep (ch)
+  (string-match "[[:blank:]]"  (string ch)))
+
+(defun* freerdp-remove-previous-spaces (&optional (from (point)))
+  (save-excursion
+   (goto-char from)
+   (while (spacep (char-before))
+          (delete-region (1- (point)) (point)))))
+
+
+(defun freerdp-electric-space-after (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+      (progn
+        (freerdp-remove-previous-spaces)
+        (self-insert-command 1)
+        (insert " "))
+       (self-insert-command repeat)))
+
+(defun freerdp-electric-space-before (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+      (progn
+        (freerdp-remove-previous-spaces)
+        (insert " ")
+        (self-insert-command 1))
+       (self-insert-command repeat)))
+
+(defun freerdp-electric-space-before-after (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+      (progn
+        (freerdp-remove-previous-spaces)
+        (insert " ")
+        (self-insert-command 1)
+        (insert " "))
+       (self-insert-command repeat)))
+
+
+(defun freerdp-electric-space-before-after-double (repeat)
+  (interactive "p")
+  (let ((ch      (this-command-keys))
+        (include nil))
+   (if (and (= 1 repeat) (stringp ch) (= 1 (length ch)))
+       (progn
+         (freerdp-remove-previous-spaces)
+         (setf include (looking-back "^#[ \t]*include" (save-excursion (beginning-of-line) (point))))
+         (when (or (/= (aref ch 0) (char-before))
+                   (=  (aref ch 0) (char-before (1- (point)))))
+           (insert " "))
+         (self-insert-command 1)
+         (unless include
+           (insert " ")))
+       (self-insert-command repeat))))
+
+(defun freerdp-electric-space-before-after-= (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+       (let ((=-prefixes "-+!<=>&|^*/"))
+         (freerdp-remove-previous-spaces)
+         (when  (if (= ?= (char-before))
+                    (position (char-before (1- (point))) =-prefixes)
+                    (not (position (char-before) =-prefixes)))
+           (insert " "))
+         (self-insert-command 1)
+         (insert " "))
+       (self-insert-command repeat)))
+
+(defun* freerdp-reverse-skip-spaces (&optional (from (point)))
+  (while (spacep (char-before from))
+         (decf from))
+  from)
+
+
+(defun freerdp-electric-space-before-after-> (repeat)
+  "Same as freerdp-electric-space-before-after-double
+unless -> in which case we remove the spaces."
+  (interactive "p")
+  (if (= 1 repeat)
+      (if (save-excursion (beginning-of-line)
+                          (thing-at-point-looking-at "[\t ]*#"))
+          (self-insert-command repeat)
+          (let ((space-after t))
+            ;;  x - - | x--  | x-- > | x-- >
+            ;;  x - > | x->a |
+            ;;  x>    | x >  |
+            (freerdp-remove-previous-spaces)
+            (if (= ?- (char-before))
+                (let ((pos (freerdp-reverse-skip-spaces (1- (point)))))
+                  (if (= ?- (char-before pos))
+                      (insert " ")
+                      (progn
+                        (freerdp-remove-previous-spaces (- (point) 1))
+                        (freerdp-remove-previous-spaces (- (point) 2))
+                        (setf space-after nil))))
+                (insert " "))
+            (self-insert-command 1)
+            (when space-after (insert " "))))
+      (self-insert-command repeat)))
+
+(defun freerdp-electric-space-before-after-*/ (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+       (let ((ch (this-command-keys)))
+         (freerdp-remove-previous-spaces)
+         (when (cond
+                 ((string= "*" ch) (and (/= ?/  (char-before))
+                                        (/= ?\( (char-before))))
+                 ((string= "/" ch) (and (/= ?*  (char-before))
+                                        (/= ?/  (char-before))))
+                 (t                t))
+           (insert " "))
+         (self-insert-command 1)
+         (unless (and (string= "*" ch) (looking-at "[()]"))
+           (insert " ")))
+       (self-insert-command repeat)))
+
+
+
+(defun freerdp-electric-brace-open (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+      (let ((start (point)))
+        (freerdp-remove-previous-spaces)
+        (insert "\n")
+        (self-insert-command 1)
+        (insert "\n\n}\n")
+        (indent-region start (point))
+        (previous-line 2)
+        (c-indent-or-tab))
+       (self-insert-command repeat)))
+
+(defun freerdp-electric-brace-close (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+      (progn
+        (if (search-forward "}" nil t)
+            (forward-char)
+            (let ((start (point)))
+              (insert "\n}\n")
+              (indent-region start (point)))))
+       (self-insert-command repeat)))
+
+(defun freerdp-c-keyword-p (string-designator)
+   (intern-soft (etypecase string-designator
+                    (symbol    (symbol-name (symbol-at-point)))
+                    (string    string-designator)
+                    (character (string string-designator)))
+                c-keywords-obarray))
+
+(defun freerdp-electric-special-character-p (ch)
+  (string-match "[[:punct:]]" (string ch)))
+
+(defvar freerdp-electric-identifier-character-regexp "[[:alnum:]_]")
+
+
+(defun freerdp-electric-paren-open (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+      (progn
+        (if (and (looking-at freerdp-electric-identifier-character-regexp)
+                 ;; (looking-back freerdp-electric-identifier-character-regexp (- (point) 1))
+                 )
+            (insert "()")
+            (progn
+              (freerdp-remove-previous-spaces)
+              (let ((current (point)))
+                (cond
+                  ((bolp)
+                   (insert "()"))
+                  (t
+                   (backward-sexp)
+                   (if (prog1 (freerdp-c-keyword-p (symbol-at-point))
+                         (forward-sexp))
+                       (insert " ()")
+                       (insert "()")))))))
+        (backward-char))
+      (self-insert-command repeat)))
+
+(defun freerdp-electric-paren-close (repeat)
+  (interactive "p")
+  (if (= 1 repeat)
+      (progn
+        (if (search-forward ")" nil t)
+            (progn) ;;            (forward-char)
+            (insert ")")))
+       (self-insert-command repeat)))
+
+
+(defun freerdp-style-set-local-bindings ()
+  (interactive)
+  (setf indent-tabs-mode t
+        tab-width        8)
+  (local-set-key "," 'freerdp-electric-space-after)
+  (local-set-key "=" 'freerdp-electric-space-before-after-=)
+  (local-set-key ">" 'freerdp-electric-space-before-after->)
+  (dolist (key '("<" "+" "-" "&" "|"))
+    (local-set-key key 'freerdp-electric-space-before-after-double))
+  (dolist (key '("*" "/"))
+    (local-set-key key 'freerdp-electric-space-before-after-*/))
+  (dolist (key '("%" "^"))
+    (local-set-key key 'freerdp-electric-space-before-after))
+  (local-set-key "{" 'freerdp-electric-brace-open)
+  (local-set-key "}" 'freerdp-electric-brace-close)
+  (local-set-key "(" 'freerdp-electric-paren-open)
+  (local-set-key ")" 'freerdp-electric-paren-close))
+
+(defun freerdp-style-mode-off ()
+  (interactive)
+  (setf indent-tabs-mode nil
+        tab-width        4)
+  (dolist (chord '("," "=" ">" "<" "+" "-" "&" "|"
+                   "*" "/" "%" "^" "{" "}" "(" ")"))
+    (local-unset-key chord)))
+
+
+(provide 'freerdp-c-style)
+;;;; THE END ;;;;
diff --git a/pjb-advices.el b/pjb-advices.el
index c1d6b99..60e86a5 100644
--- a/pjb-advices.el
+++ b/pjb-advices.el
@@ -197,7 +197,7 @@ Email addresses are not case sensitive."
       ad-do-it
       (unless (eq window-system 'w32)
         (if focus-follows-mouse
-            (set-mouse-position (selected-frame) (1- (frame-width)) 0)
+            (set-mouse-position (selected-frame) (1- (pjb-frame-width)) 0)
             (redirect-frame-focus original-frame (selected-frame))))))
   (ad-activate 'other-frame))

@@ -392,4 +392,3 @@ delete any existing frames that the frame configuration doesn't mention.

 ;; (provide 'pjb-advices)
 ;;;; THE END ;;;;
-
diff --git a/pjb-banks.el b/pjb-banks.el
index 1a17320..0fff767 100644
--- a/pjb-banks.el
+++ b/pjb-banks.el
@@ -72,7 +72,7 @@ RETURN: A cleaned string where the comas are replaced by dots,
         (i 0)
         (result '()))
       ((null items) (apply (function concatenate) 'string (nreverse result)))
-    (unless (zerop (length (string-trim " " item)))
+    (unless (zerop (length (cl:string-trim " " item)))
       (incf i)
       (push (format "%10s" item) result)
       (when (zerop (mod i 6))
@@ -131,8 +131,8 @@ Use Mozilla, and copy-and-paste to emacs."
                (sol (match-string-no-properties 7 line))
                ;; (mat (match-lines))
                (lin) (ori))
-          (setf deb (string-trim " " deb)
-                cre (string-trim " " cre)
+          (setf deb (cl:string-trim " " deb)
+                cre (cl:string-trim " " cre)
                 y (+ y (cond ((and (= mv 12) (= m 1)) 1999)
                              ((and (= mv 1) (= m 12)) 2001)
                              (t                       2000)))
@@ -162,7 +162,7 @@ Use Mozilla, and copy-and-paste to emacs."
                      (if (< (length lab) 48) lab
                          (replace-regexp-in-string
                           "\n" "\n                "
-                          (string-trim " " (string-justify-left lab 48)))))
+                          (cl:string-trim " " (string-justify-left lab 48)))))
                   ,(cond
                     ((string-match "HACIENDA\\|SEGURIDAD" lab)
                      ":IMPUESTO")
@@ -222,8 +222,8 @@ Use Mozilla, and copy-and-paste to emacs."
                ;; (mat (match-lines))
                (lin) (ori))
           (message "%S %S %S" deb cre sol)
-          (setf deb (string-trim " " deb)
-                cre (string-trim " " cre)
+          (setf deb (cl:string-trim " " deb)
+                cre (cl:string-trim " " cre)
                 y (+ y (cond ((and (= mv 12) (= m 1)) 1999)
                              ((and (= mv 1) (= m 12)) 2001)
                              (t                       2000)))
diff --git a/pjb-c.el b/pjb-c.el
index df511fc..28d1085 100644
--- a/pjb-c.el
+++ b/pjb-c.el
@@ -319,7 +319,100 @@ SEE ALSO:       c-indent-line
 ;;;                                         ;  is when the TAB command is used.


-
-
-
-;;;; pjb-c.el                         -- 2003-10-10 23:50:40 -- pascal   ;;;;
+(defvar *pjb-c-word-size* 64 "Number of bits in a unsigned long long.")
+(defun pjb-c-label-function (name enum-type enum-constants)
+  (let* ((word-size   64)
+         (max-width   (loop for constant in enum-constants
+                            maximize (length (prin1-to-string constant))))
+         (case-format (format "    case %%-%ds: return %%S;\n" max-width))
+         (buffer-size (+ (length "Invalid  value: ")
+                         (length (prin1-to-string enum-type))
+                         (ceiling (* *pjb-c-word-size* (log 2 10)))
+                         1 ; terminating null
+                         16 ; safety.
+                         )))
+    (concat (format "const char* %s(%s value){
+    switch(value){
+" name enum-type)
+            (mapconcat (lambda (constant) (format case-format constant (prin1-to-string constant)))
+                       enum-constants "")
+            (format "    default: {
+        static char buffer[%d];
+        sprintf(buffer,\"Invalid %s value: %%d\",value);
+        return buffer;
+    }}
+}
+" buffer-size enum-type))))
+
+
+(assert (string= (pjb-c-label-function 'get_label 'foo '(foo_foo foo_bar foo_chiang))
+         "const char* get_label(foo value){
+    switch(value){
+    case foo_foo   : return \"foo_foo\";
+    case foo_bar   : return \"foo_bar\";
+    case foo_chiang: return \"foo_chiang\";
+    default: {
+        static char buffer[56];
+        sprintf(buffer,\"Invalid foo value: %d\",value);
+        return buffer;
+    }}
+}
+"))
+
+
+
+(defun ensure-string (object)
+  (typecase object
+    (symbol (symbol-name object))
+    (string object)
+    (t (prin1-to-string object))))
+
+(defun substitute-strings (substitutions string)
+  (with-temp-buffer
+      (loop
+        for (old new) in substitutions
+          initially (insert string)
+        do (replace-string (ensure-string old)
+                           (ensure-string new)
+                           nil (point-min) (point-max))
+        finally (return (buffer-substring-no-properties (point-min) (point-max))))))
+
+(when nil
+  (progn
+    (loop
+      for <T> in '("A" "W")
+      for TCHAR in '("char" "WCHAR")
+      do (insert (substitute-strings (list (list '<T> <T>) (list 'TCHAR TCHAR))
+                                 "
+BOOL contains<T> (TCHAR * string, char * substring)
+{
+    int wlen = strlen<T>(string);
+    int slen = strlen(substring);
+    int end = wlen - slen;
+    int i = 0;
+    for (i = 0; i < end; i ++ )
+    {
+        if (ncompare<T>(string + i, substring, slen) == 0)
+        {
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+")))
+    (insert "
+BOOL contains (int widechar, BYTE * string, char * substring)
+{
+    if (widechar)
+    {
+        return containsW((WCHAR*)string,substring);
+    }
+    else
+    {
+        return containsA((char*)string,substring);
+    }
+}
+")))
+
+
+;;;; THE END ;;;;
diff --git a/pjb-cl.el b/pjb-cl.el
index 5d63589..54b7315 100644
--- a/pjb-cl.el
+++ b/pjb-cl.el
@@ -1127,7 +1127,7 @@ DO:     [cltl2] string= compares two strings and is true if they are
   (make-string size initial-element))


-(defun string-trim (character-bag string-designator)
+(defun cl:string-trim (character-bag string-designator)
   "Common-Lisp: returns a substring of string, with all characters in \
 character-bag stripped off the beginning and end.
 "
diff --git a/pjb-emacs.el b/pjb-emacs.el
index e741d54..21475d7 100644
--- a/pjb-emacs.el
+++ b/pjb-emacs.el
@@ -53,7 +53,7 @@



-(defvar html-quick-keys t )
+(defvar html-quick-keys t)
 (defvar html-mode-map
   (let ((map (nconc (make-sparse-keymap) sgml-mode-map))
         (menu-map (make-sparse-keymap "HTML")))
@@ -137,6 +137,7 @@


 (defun recover-this-file ()
+  "Recovers the file of the current buffer, if any."
   (interactive)
   (let ((file-path  (buffer-file-name)))
     (if (and file-path (file-exists-p file-path) (file-regular-p file-path))
@@ -144,6 +145,19 @@
         (message "This buffer has no associated file."))))


+(defun delete-this-file (kill-buffer)
+  "Deletes the file of the current buffer, if any.
+When KILL-BUFFER is true (command prefix), also kills the buffer."
+  (interactive "P")
+  (let ((file-path  (buffer-file-name)))
+    (if (and file-path (file-exists-p file-path) (file-regular-p file-path))
+        (progn
+          (delete-file file-path)
+          (when kill-buffer
+            (kill-buffer)))
+        (message "This buffer has no associated file."))))
+
+
 (defvar buffer-name-map   nil)
 (defvar buffer-list-cache nil)

@@ -1025,7 +1039,7 @@ RETURN: The current frame.


 (defmacro define-frame-parameter (name)
-  `(defun ,(intern (format "frame-%s" name)) (&optional frame)
+  `(defun ,(intern (format "pjb-frame-%s" name)) (&optional frame)
      ,(format "Returns the %s parameter of the `frame'." name)
      (frame-parameter (or frame (selected-frame)) ',name)))

@@ -1093,7 +1107,7 @@ RETURN: The current frame.



-(defun max-frame-line-number (&optional frame)
+(defun pjb-frame-max-line-number (&optional frame)
   "
 RETURN: The maximum number of line that can be displayed on this frame
         inside this screen.
@@ -1103,7 +1117,7 @@ RETURN: The maximum number of line that can be displayed on this frame
       (frame-char-height frame))))


-(defun max-frame-column-number (&optional frame margin)
+(defun pjb-frame-max-column-number (&optional frame margin)
   "
 MARGIN: Number of pixel to substract from the display width.
 RETURN: The maximum number of columns that can be displayed on this frame
@@ -1120,9 +1134,9 @@ RETURN: The maximum number of columns that can be displayed on this frame
   (interactive)
   (let ((*current-frame* (current-frame)))
     (set-frame-width  *current-frame*
-                      (max-frame-column-number
+                      (pjb-frame-max-column-number
                        *current-frame* (+ (if current-prefix-arg 64 0) 34)))
-    (set-frame-height *current-frame* (max-frame-line-number *current-frame*))
+    (set-frame-height *current-frame* (pjb-frame-max-line-number *current-frame*))
     (set-frame-position *current-frame* 0 0)
     (delete-other-windows)))

@@ -1145,8 +1159,8 @@ RETURN: The maximum number of columns that can be displayed on this frame
   (interactive "NOffset: ")
   (let ((*current-frame* (current-frame)))
     (set-frame-position *current-frame*
-                        (+ offset (eval (frame-pixel-left *current-frame*)))
-                        (eval (frame-pixel-top *current-frame*)))))
+                        (+ offset (eval (pjb-frame-pixel-left *current-frame*)))
+                        (eval (pjb-frame-pixel-top *current-frame*)))))


 (defun move-frame-down (offset)
@@ -1154,8 +1168,8 @@ RETURN: The maximum number of columns that can be displayed on this frame
   (interactive "NOffset: ")
   (let ((*current-frame* (current-frame)))
     (set-frame-position *current-frame*
-                        (eval (frame-pixel-left *current-frame*))
-                        (+ offset (eval (frame-pixel-top *current-frame*))))))
+                        (eval (pjb-frame-pixel-left *current-frame*))
+                        (+ offset (eval (pjb-frame-pixel-top *current-frame*))))))

 (defun move-frame-to (args)
   (interactive "X'(left top)= ")
@@ -1215,7 +1229,7 @@ SEE:   position-y"
            (position-x (second pos) frame)
            (error "Unexpected x position: %S" pos)))
       ((minusp pos)
-       (- (+ pos (frame-pixel-width frame))  (x-display-pixel-width  frame)))
+       (- (+ pos (pjb-frame-pixel-width frame))  (x-display-pixel-width  frame)))
       (t pos))))


@@ -1237,7 +1251,7 @@ SEE:   position-x
            (position-y (second pos) frame)
            (error "Unexpected y position: %S" pos)))
       ((minusp pos)
-       (- (+ pos (frame-pixel-height frame))  (x-display-pixel-height  frame)))
+       (- (+ pos (pjb-frame-pixel-height frame))  (x-display-pixel-height  frame)))
       (t pos))))


@@ -1251,10 +1265,10 @@ NOTE:   For multi-screen displays, the coordinate system could be such that
         (+ -|x|) (+ -|y|).
 "
   (let ((frame (or frame (current-frame))))
-    (let ((x (frame-pixel-left frame))
-          (y (frame-pixel-top  frame)))
+    (let ((x (pjb-frame-pixel-left frame))
+          (y (pjb-frame-pixel-top  frame)))
       (set-frame-position frame 0 0)
-      (prog1 (list (frame-pixel-left frame) (frame-pixel-top frame))
+      (prog1 (list (pjb-frame-pixel-left frame) (pjb-frame-pixel-top frame))
         (set-frame-position frame (position-x x) (position-y y))))))

 (defun screen-usable-area (&optional frame)
@@ -1278,7 +1292,7 @@ RETURN: The origin and width and height of the screen where the frame lies,

 (defvar *frame-maximized-states*)

-;; (list (frame-pixel-left) (frame-pixel-top) (frame-width) (frame-height))
+;; (list (frame-pixel-left) (frame-pixel-top) (pjb-frame-width) (pjb-frame-height))
 ;; (0 (+ -23) 179 78)


@@ -1432,10 +1446,10 @@ Multiply by -1 = without decoration.
                               (if (and (eq window-system 'ns) decorationp) 64 0))))
               (labels ((mesframe (frame)
                          (message "0: x=%8S y=%8S w=%8S h=%8S"
-                                  (frame-pixel-left frame)
-                                  (frame-pixel-top frame)
-                                  (frame-pixel-width frame)
-                                  (frame-pixel-height frame)))
+                                  (pjb-frame-pixel-left frame)
+                                  (pjb-frame-pixel-top frame)
+                                  (pjb-frame-pixel-width frame)
+                                  (pjb-frame-pixel-height frame)))
                        (move-frame (x w y h)
                          ;; (mesframe frame)
                          (message "1: x=%8S y=%8S w=%8S h=%8S" x y w h)
@@ -1449,8 +1463,8 @@ Multiply by -1 = without decoration.
                          ;; (mesframe frame)
                          (setf x (position-x x)
                                y (position-y y)
-                               w (frame-pixel-width  frame)
-                               h (frame-pixel-height frame))
+                               w (pjb-frame-pixel-width  frame)
+                               h (pjb-frame-pixel-height frame))
                          (message "2: x=%8S y=%8S w=%8S h=%8S" x y w h)
                          (set-frame-position frame x y)
                          ;; (mesframe frame)
@@ -1463,7 +1477,7 @@ Multiply by -1 = without decoration.
   (interactive)
   (let ((*current-frame* (current-frame)))
     (set-frame-width *current-frame* 81)
-    (set-frame-height *current-frame* (max-frame-line-number))
+    (set-frame-height *current-frame* (pjb-frame-max-line-number))
     (if current-prefix-arg
         (set-frame-position *current-frame* -1  0)
         (set-frame-position *current-frame* -64 0))
@@ -1476,7 +1490,7 @@ Multiply by -1 = without decoration.
   (let ((*current-frame* (current-frame)))
     (setq truncate-partial-width-windows nil)
     (set-frame-width *current-frame* 167)
-    (set-frame-height *current-frame* (max-frame-line-number))
+    (set-frame-height *current-frame* (pjb-frame-max-line-number))
     (set-frame-position *current-frame* 0 0)
     (delete-other-windows)
     (split-window-horizontally 86)
@@ -1536,9 +1550,9 @@ Multiply by -1 = without decoration.
                                   (cdr (assoc 'top fp)))
                             (cdr (assoc 'width fp))
                             (cdr (assoc 'height fp))))
-          (set-frame-width  frame (max-frame-column-number frame 34))
+          (set-frame-width  frame (pjb-frame-max-column-number frame 34))
           ;; I don't know where these 34 go?
-          (set-frame-height frame (max-frame-line-number   frame))
+          (set-frame-height frame (pjb-frame-max-line-number   frame))
           (set-frame-position frame 0 0)))
     (setf (gethash frame *frame-maximized-states*) state)))

@@ -1574,31 +1588,31 @@ only display one window with the scratch buffer"
          (screen-height (fourth area))
          (other-frames  (remove-if
                          (lambda (fr) (or (eq fr frame)
-                                     (not (equal (frame-display fr)
-                                                 (frame-display frame)))))
+                                     (not (equal (pjb-frame-display fr)
+                                                 (pjb-frame-display frame)))))
                          (frame-list))))
     (select-frame frame)
     (case (length other-frames)
       ((0) (full-frame 3))              ; by default go to the right.
-      ((1) (let ((left (eval (frame-pixel-left (first other-frames)))))
+      ((1) (let ((left (eval (pjb-frame-pixel-left (first other-frames)))))
              (if (< left (truncate (- screen-width 20) 2))
                  (full-frame 3)
                  (full-frame 2))))
       (otherwise
        (let ((used-squares '()))
          (dolist (fr other-frames)
-           (let ((h (if (< (eval (frame-pixel-left fr))
+           (let ((h (if (< (eval (pjb-frame-pixel-left fr))
                            (- (truncate screen-width  2) *window-manager-x-offset*))
                         ;; on the left 46 [+ 57]
-                        (if (<= (frame-pixel-width fr) (truncate screen-width 2))
+                        (if (<= (pjb-frame-pixel-width fr) (truncate screen-width 2))
                             '(4 6)
                             '(4 6 5 7))
                         ;; on the right 57 whatever.
                         '(5 7)))
-                 (v (if (< (eval (frame-pixel-top fr))
+                 (v (if (< (eval (pjb-frame-pixel-top fr))
                            (- (truncate screen-height 2) *window-manager-y-offset*))
                         ;; on the top 45 [+ 67]
-                        (if (<= (frame-pixel-height fr) (truncate screen-height 2))
+                        (if (<= (pjb-frame-pixel-height fr) (truncate screen-height 2))
                             '(4 5)
                             '(4 5 6 7))
                         ;; on the bottom whatever.
@@ -1624,10 +1638,10 @@ only display one window with the scratch buffer"
                  nil ; no repeat
                  (lambda () ; a closure, thanks to lexical-binding above :-)
                    (toggle-tool-bar-mode-from-frame +1)
-                   (set-frame-size frame (1- (frame-width frame)) (1- (frame-height frame)))
+                   (set-frame-size frame (1- (pjb-frame-width frame)) (1- (pjb-frame-height frame)))
                    (forward-font -1)
                    (forward-font +1)
-                   (set-frame-size frame (1+ (frame-width frame)) (1+ (frame-height frame)))
+                   (set-frame-size frame (1+ (pjb-frame-width frame)) (1+ (pjb-frame-height frame)))
                    (toggle-tool-bar-mode-from-frame -1)))))

 (when (eq window-system 'ns)
diff --git a/pjb-erc.el b/pjb-erc.el
index 575258a..eaa510c 100644
--- a/pjb-erc.el
+++ b/pjb-erc.el
@@ -255,16 +255,16 @@
   (let* ((header-end (or (search "\r\n\r\n" http-output)
                          (search "\n\n" http-output)))
          (headers (mapcar
-                   (lambda (line) (string-trim "\r" line))
+                   (lambda (line) (cl:string-trim "\r" line))
                    (split-string (subseq http-output 0 header-end) "\n"))))
     (values
      (first headers)
      (mapcar (lambda (header)
                (let ((colon (position (character ":") header)))
-                 (cons (string-trim " " (subseq header 0 colon))
-                       (string-trim " " (subseq header (1+ colon))))))
+                 (cons (cl:string-trim " " (subseq header 0 colon))
+                       (cl:string-trim " " (subseq header (1+ colon))))))
              (rest headers))
-     (string-trim "\r\n" (subseq http-output  header-end)))))
+     (cl:string-trim "\r\n" (subseq http-output  header-end)))))

 (defun pjb-http-session (method url headers data)
   (with-temp-buffer
@@ -596,7 +596,7 @@ displaying erc buffers."
 (defun pjb-erc-user-input ()
   "Return the input of the user in the current buffer."
   ;; We use erc-bol to ignore the prompt.
-  (string-trim "\n" (buffer-substring
+  (cl:string-trim "\n" (buffer-substring
                      (progn
                        (goto-char (erc-beg-of-input-line))
                        (erc-bol))
@@ -1124,8 +1124,10 @@ command).
                (("#emacs")
                 . el-eval-last-expression)
                (("#scheme")
-                . scheme-eval-last-expression))
-        when (member* current-channel channels :test (function string=))
+                . scheme-eval-last-expression)
+               (t . cl-eval-last-expression))
+        when (or (eql channels t)
+                 (member* current-channel channels :test (function string=)))
           do (local-set-key (kbd "C-x C-e") eval-function)))

 (add-hook 'erc-join-hook 'pjb/erc-join-meat)
diff --git a/pjb-loader.el b/pjb-loader.el
index 1ec20af..337e85e 100644
--- a/pjb-loader.el
+++ b/pjb-loader.el
@@ -52,7 +52,7 @@
       (delete-file "--version.lock"))
     (when show-messages
       (switch-to-buffer "*Messages*")
-      (split-window-vertically))))
+      (ignore-errors (split-window-vertically)))))


 (defvar *pjb-sources* '())
diff --git a/pjb-math.el b/pjb-math.el
new file mode 100644
index 0000000..d4e3084
--- /dev/null
+++ b/pjb-math.el
@@ -0,0 +1,99 @@
+;;;; -*- mode:emacs-lisp;coding:utf-8 -*-
+;;;;**************************************************************************
+;;;;FILE:               pjb-math.el
+;;;;LANGUAGE:           emacs lisp
+;;;;SYSTEM:             POSIX
+;;;;USER-INTERFACE:     NONE
+;;;;DESCRIPTION
+;;;;
+;;;;    Defines bindings for maths symols.
+;;;;
+;;;;AUTHORS
+;;;;    <PJB> Pascal J. Bourguignon <pjb@informatimago.com>
+;;;;MODIFICATIONS
+;;;;    2018-12-13 <PJB> Created.
+;;;;BUGS
+;;;;LEGAL
+;;;;    AGPL3
+;;;;
+;;;;    Copyright Pascal J. Bourguignon 2018 - 2018
+;;;;
+;;;;    This program is free software: you can redistribute it and/or modify
+;;;;    it under the terms of the GNU Affero General Public License as published by
+;;;;    the Free Software Foundation, either version 3 of the License, or
+;;;;    (at your option) any later version.
+;;;;
+;;;;    This program is distributed in the hope that it will be useful,
+;;;;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;;    GNU Affero General Public License for more details.
+;;;;
+;;;;    You should have received a copy of the GNU Affero General Public License
+;;;;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;;;**************************************************************************
+
+
+(setf lexical-binding t)
+(defun set-math-bindings (prefix)
+  (dolist (item '(
+                  "`~∞∝" "1!₁¹" "2@₂²" "3#₃³" "4$₄⁴" "5%₅⁵" "6^₆⁶" "7&₇⁷" "8*₈⁸" "9(₉⁹" "0)₀⁰" "-_⊣⊥" "=+⊢⊤"
+;; Math chars:
+;; ℂℍℕℙℚℝℤℼℽℾℿ⅀ⅅⅆⅇⅈⅉ
+;; ℬℰℱℋℐℒℳ℘ℛ
+
+                  "qQωΩ" "wW€¢" "eEεΕ" "rRρΡ" "tTτΤ" "yYψΨ" "uUυΥ" "iIιΙ" "oOοΟ" "pPπΠ" "[{«∀" "]}»∃"  "\\|\∖∫"
+                  "aAαΑ" "sSσΣ" "dDδΔ" "fFφΦ" "gGγΓ" "hHθΘ" "jJηΗ" "kKκΚ" "lLλΛ" ";:⊆⎕" "'\"⊇○"
+                  "zZζΖ" "xXξΞ" "cCχΧ" "vV∇√" "bBβΒ" "nNνΝ" "mMμΜ" ",<≤∧" ".>≥∨" "/?≠¬"
+                  (pause  "∂")
+                  (insert "∈∉")   (home "⇒⇔")    (prior "≡≢")
+                  (delete "∅≣")   (end "∴∵")     (next "≈≇")
+                  (up "↑∩")
+                  (left "←⊂")    (down "↓∪")    (right "→⊃")))
+    (cond
+      ((stringp item)
+       (let ((l (aref item 0)) (lm (string (aref item 2)))
+             (s (aref item 1)) (sm (string (aref item 3))))
+         (local-set-key (kbd (format "%s %c" prefix l))
+                        (lambda (n)
+                          (interactive "p")
+                          (dotimes (i n) (insert lm))))
+         (local-set-key (kbd (format "%s %c" prefix s))
+                        (lambda (n)
+                          (interactive "p")
+                          (dotimes (i n) (insert sm))))))
+      ((listp item)
+       (let ((y (elt item 0))
+             (lm (string (aref (elt item 1) 0)))
+             (sm (when (< 1 (length (elt item 1)))
+                   (string (aref (elt item 1) 1)))))
+         (local-set-key (kbd (format "%s <%s>" prefix y))
+                        (lambda (n)
+                          (interactive "p")
+                          (dotimes (i n) (insert lm))))
+         (when sm
+           (local-set-key (kbd (format "%s S-<%s>" prefix y))
+                          (lambda (n)
+                            (interactive "p")
+                            (dotimes (i n) (insert sm))))))))))
+
+(defun set-greek-bindings (prefix)
+  (dolist (item '(
+                  "qQωΩ" "wW€¢" "eEεΕ" "rRρΡ" "tTτΤ" "yYψΨ" "uUυΥ" "iIιΙ" "oOοΟ" "pPπΠ"
+                  "aAαΑ" "sSσΣ" "dDδΔ" "fFφΦ" "gGγΓ" "hHθΘ" "jJηΗ" "kKκΚ" "lLλΛ"
+                  "zZζΖ" "xXξΞ" "cCχΧ" "vV∇√" "bBβΒ" "nNνΝ" "mMμΜ"))
+    (let ((l (aref item 0)) (lm (string (aref item 2)))
+          (s (aref item 1)) (sm (string (aref item 3))))
+      (local-set-key (kbd (format "%s %c" prefix l))
+                     (lambda (n)
+                       (interactive "p")
+                       (dotimes (i n) (insert lm))))
+      (local-set-key (kbd (format "%s %c" prefix s))
+                     (lambda (n)
+                       (interactive "p")
+                       (dotimes (i n) (insert sm)))))))
+
+
+(set-greek-bindings "C-c g")
+(set-math-bindings "C-c m")
+
+(provide 'pjb-math)
diff --git a/pjb-objc-ide.el b/pjb-objc-ide.el
index a51d8fa..e8ca6c9 100644
--- a/pjb-objc-ide.el
+++ b/pjb-objc-ide.el
@@ -375,7 +375,7 @@ This command assumes point is not in a string or comment."
 (defun pjb-ide-insert-tag-comment (&optional tag)
   (interactive "p")
   (let ((tag   (or tag 0)))
-    (unless (string= "" (string-trim " \t" (pjb-ide-beginning-of-line-to-point)))
+    (unless (string= "" (cl:string-trim " \t" (pjb-ide-beginning-of-line-to-point)))
       (insert "\n"))
     (if (region-active-p)
         (let ((start (region-beginning))
diff --git a/pjb-searches.el b/pjb-searches.el
index 05b0021..cd83370 100644
--- a/pjb-searches.el
+++ b/pjb-searches.el
@@ -73,7 +73,7 @@
    (browse-url
     (format "https://developer.apple.com/library/mac/search/?q=%s"
             (browse-url-url-encode-chars
-             (string-trim *whitespaces* search-string)
+             (cl:string-trim *whitespaces* search-string)
              "[^A-Za-z0-9]")))))

 (defun osx-search-region (start end)
@@ -89,7 +89,7 @@
       (browse-url
        (format "https://developer.apple.com/library/ios/search/?q=%s"
                (browse-url-url-encode-chars
-                (string-trim *whitespaces* search-string)
+                (cl:string-trim *whitespaces* search-string)
                 "[^A-Za-z0-9]")))))

 (defun ios-search-region (start end)
@@ -113,7 +113,7 @@
                                 (mapconcat (function identity) words "/")))))
                   (format "http://developer.android.com/reference/index.html?q=%s"
                           (browse-url-url-encode-chars
-                           (string-trim *whitespaces* search-string)
+                           (cl:string-trim *whitespaces* search-string)
                            "[^A-Za-z0-9]")))))

 (defun android-search-region (start end)
@@ -121,6 +121,40 @@
   (interactive "r")
   (%search-region start end 'symbol 'android-search))

+
+(defvar *pjb-search-exclude*            '("debug" "release" ".svn" ".git" ".hg" ".cvs"))
+(defvar *pjb-search-include-extensions* '("xib" "h" "c" "m" "hh" "cc" "mm" "hxx" "cxx"
+                                          "lisp" "asd" "cl" "el"
+                                          "rb" "java" "xml"
+                                          "logs" "txt" "html" "iml"
+                                          "json" "md" "prefs"
+                                          "project" "properties"
+                                          "sh" "bash"))
+(defun git-search (search-string)
+  "Search a regex in the current git repository (with `find-grep' and `grep-find-command')."
+  (interactive "sSearch Git Regexp: ")
+  (let ((exclude *pjb-search-exclude*)
+        (include (mapcar (lambda (extension) (format "\\*.%s" extension))
+                         *pjb-search-include-extensions*)))
+    (find-grep (format "find %S \\( \\( %s \\) -prune \\) -o -type f %s -print0 | xargs -0 grep -nHi -e %s"
+
+                       (expand-file-name (vc-git-root (or (buffer-file-name) default-directory)))
+                       (mapconcat (lambda (name) (format "-name %s" name)) exclude " -o ")
+                       (if include
+                           (format "\\( %s \\)" (mapconcat (lambda (name) (format "-name %s" name)) include " -o "))
+                           "")
+                       (shell-quote-argument search-string)))))
+
+(defun git-search-region (start end)
+  "Search the text in the region in the current git repository."
+  (interactive "r")
+  (%search-region start end 'symbol 'git-search))
+
+(defun git-search-symbol-at-point ()
+  "Search the symbol at point in the current git repository."
+  (interactive)
+  (git-search (symbol-name (symbol-at-point))))
+
 (defun project-search (search-string)
   "Search a regex in the current project (with `find-grep' and `grep-find-command')."
   (interactive "sSearch Project Regexp: ")
@@ -139,7 +173,7 @@
    (format "http://www.google.com/search?as_q=%s&num=50&hl=en&ie=ISO8869-1&btnG=Google+Search&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=&as_qdr=all&as_nlo=&as_nhi=&as_occt=any&as_dt=i&as_s
 itesearch=&safe=images"
            (browse-url-url-encode-chars
-            (string-trim *whitespaces* search-string)
+            (cl:string-trim *whitespaces* search-string)
             "[^A-Za-z0-9]"))))

 (defun google-search-region (start end)
@@ -206,6 +240,7 @@ itesearch=&safe=images"

 ;;(global-set-key (kbd "C-h 1") 'android-search-region)
 ;;(global-set-key (kbd "C-h 1") 'osx-search-region)
+
 (global-set-key (kbd "C-h 1") 'ios-search-region)
 (global-set-key (kbd "C-h 2") 'google-search-region)
 (global-set-key (kbd "C-h 3") 'acronym-search-region)
@@ -213,7 +248,12 @@ itesearch=&safe=images"
 (global-set-key (kbd "C-h 5") 'includes-search-region)
 (global-set-key (kbd "C-h 6") 'hyperspec-search-region)
 (global-set-key (kbd "C-h 7") 'here-search-region)
-(global-set-key (kbd "C-h 0") 'android-browse-documentation-of-class-at-point)
+(global-set-key (kbd "C-h 8") 'git-search-region)
+
+(global-set-key (kbd "H-s")   'git-search-symbol-at-point)
+(global-set-key (kbd "C-H-s") 'git-search)
+(global-set-key (kbd "M-H-s") 'git-search-region)
+

 (defun set-osx-search-region-function ()
   (interactive)
diff --git a/pjb-sources.el b/pjb-sources.el
index be714e5..8c7fca6 100644
--- a/pjb-sources.el
+++ b/pjb-sources.el
@@ -1128,9 +1128,9 @@ RETURN: The list of results from fun.
 ;; selector function.
 ;;

-(defun get-sexps (source-file &key (selector (function (lambda (s) t)))
-                                (deeply   nil)
-                                (atoms    nil))
+(defun* get-sexps (source-file &key (selector (function (lambda (s) t)))
+                               (deeply   nil)
+                               (atoms    nil))
   "
 KEYS:    :selector (function: sexp --> boolean, default: (lambda (s) t))
          :deeply   (boolean,  default nil)
@@ -3536,8 +3536,10 @@ SProject Type: ")
                                                                     (b (car b)))
                                                                (or (< (length a) (length b))
                                                                    (and (= (length a) (length b))
-                                                                        (string< a b)))))))))))))
-  (global-set-key (kbd "A-f") 'sources-find-file-named))
+                                                                        (string< a b))))))))))))))
+
+(global-set-key (kbd "A-f") 'sources-find-file-named)
+(global-set-key (kbd "C-c C-x C-f") 'sources-find-file-named)



diff --git a/pjb-xresources.el b/pjb-xresources.el
index 677d8aa..de5dfde 100644
--- a/pjb-xresources.el
+++ b/pjb-xresources.el
@@ -42,10 +42,8 @@ RETURN: The current frame.


 (defmacro define-frame-parameter (name)
-  (let ((name (intern (format "frame-%s" name))))
-    (unless (fboundp name)
-      `(defun ,name (&optional frame)
-         (frame-parameter (or frame (selected-frame)) ',name)))))
+  `(defun* ,(intern (format "pjb-frame-%s" name)) (&optional frame)
+     (frame-parameter (or frame (selected-frame)) ',name)))

 ;; (dolist (p (frame-parameters)) (insert (format "(define-frame-parameter %s)\n" (car p))))

@@ -94,8 +92,12 @@ RETURN: The current frame.
 (define-frame-parameter font)


-(defalias 'frame-pixel-top  'frame-top)
-(defalias 'frame-pixel-left 'frame-left)
+(defalias 'pjb-frame-pixel-top    'pjb-frame-top)
+(defalias 'pjb-frame-pixel-left   'pjb-frame-left)
+(defalias 'pjb-frame-pixel-bottom 'pjb-frame-bottom)
+(defalias 'pjb-frame-pixel-right  'pjb-frame-right)
+(defalias 'pjb-frame-pixel-height 'pjb-frame-height)
+(defalias 'pjb-frame-pixel-width  'pjb-frame-width)


 (defun set-default-frame-parameter (name value)
@@ -106,19 +108,19 @@ RETURN: The current frame.
     value))


-(defun frame-geometry (&optional frame)
+(defun pjb-frame-geometry (&optional frame)
   "Return the position and size of the `frame' as an X geometry specification string."
   (let ((frame (or frame (current-frame))))
     (format "%dx%d-%d+%d"
-            (frame-width frame) (frame-height frame)
-            (frame-pixel-left frame) (frame-pixel-top frame))))
+            (pjb-frame-width frame)      (pjb-frame-height frame)
+            (pjb-frame-pixel-left frame) (pjb-frame-pixel-top frame))))


-(defun frame-full-screen (&optional frame)
+(defun pjb-frame-full-screen (&optional frame)
   "Return the full-screen X resource parameter for the `frame'."
   (let* ((frame    (or frame (current-frame)))
-         (fwidth   (frame-pixel-width))
-         (fheight  (frame-pixel-height))
+         (fwidth   (pjb-frame-pixel-width))
+         (fheight  (pjb-frame-pixel-height))
          (percent  0.95))
     (destructuring-bind (stop sleft sheight swidth) (screen-usable-area (current-frame))
       (flet ((within (percent a b)
@@ -178,38 +180,38 @@ RETURN: The current frame.
   (interactive)
   (generate-x-resources
    ("emacs"
-    ("*background"     (frame-background-color))
-    ("*bitmapIcon"     (on-off (frame-icon-name)))
-    ("*borderColor"    (frame-border-color))
-    ("*borderWidth"    (frame-border-width))
-    ("*cursorColor"    (frame-cursor-color))
+    ("*background"     (pjb-frame-background-color))
+    ("*bitmapIcon"     (on-off (pjb-frame-icon-name)))
+    ("*borderColor"    (pjb-frame-border-color))
+    ("*borderWidth"    (pjb-frame-border-width))
+    ("*cursorColor"    (pjb-frame-cursor-color))
     ("*cursorBlink"    (on-off blink-cursor))
-    ("*font"           (frame-font))
+    ("*font"           (pjb-frame-font))
     ("*fontBackend"    :unset)
-    ("*foreground"     (frame-foreground-color))
-    ("*geometry"       (frame-geometry))
-    ("*fullscreen"     (or-unset (frame-full-screen)))
-    ("*iconName"       (or-unset (frame-icon-name)))
-    ("*internalBorder" (frame-internal-border-width))
-    ("*lineSpacing"    (or-unset (frame-line-spacing)))
+    ("*foreground"     (pjb-frame-foreground-color))
+    ("*geometry"       (pjb-frame-geometry))
+    ("*fullscreen"     (or-unset (pjb-frame-full-screen)))
+    ("*iconName"       (or-unset (pjb-frame-icon-name)))
+    ("*internalBorder" (pjb-frame-internal-border-width))
+    ("*lineSpacing"    (or-unset (pjb-frame-line-spacing)))
     ("*menuBar"        (on-off menu-bar-mode))
-    ("*minibuffer"     (if (frame-minibuffer) :unset "none"))
+    ("*minibuffer"     (if (pjb-frame-minibuffer) :unset "none"))
     ("*paneFont"       :unset) ; how to get it?    Font name for menu pane titles, in non-toolkit versions of Emacs.
-    ("*pointerColor"   (frame-mouse-color))
+    ("*pointerColor"   (pjb-frame-mouse-color))
     ("*privateColormap" :unset) ;  If ‘on’, use a private color map, in the case where the “default visual” of class PseudoColor and Emacs is using it.
     ("*reverseVideo"   (on-off (cdr (or (assq 'reverse (frame-parameters))
                                        (assq 'reverse default-frame-alist)))))
-    ("*screenGamma"    (or-unset (frame-screen-gamma)))
-    ("*scrollBarWidth" (frame-scroll-bar-width))
+    ("*screenGamma"    (or-unset (pjb-frame-screen-gamma)))
+    ("*scrollBarWidth" (pjb-frame-scroll-bar-width))
     ("*selectionFont" :unset) ;  Font name for pop-up menu items, in non-toolkit versions of Emacs. (For toolkit versions, see Lucid Resources, also see LessTif  Resources.)
     ("*selectionTimeout" :unset) ; Number of milliseconds to wait for a selection reply. If the selection owner doesn't reply in this time, we give up. A value of 0  means wait as long as necessary.
     ("*synchronous" :unset) ; Run Emacs in synchronous mode if ‘on’. Synchronous mode is useful for debugging X problems.
-    ("*title"       (or (frame-title) (frame-name)))
+    ("*title"       (or (pjb-frame-title) (pjb-frame-name)))
     ("*toolBar" (if top-toolbar
                    top-toolbar-height
                    0))
     ("*useXIM"  :unset) ; Turn off use of X input methods (XIM) if ‘false’ or ‘off’. This is only relevant if your Emacs is actually built with XIM support.  It is potentially useful to turn off XIM for efficiency, especially slow X client/server links.
-    ("*verticalScrollBars" (on-off (frame-vertical-scroll-bars)))
+    ("*verticalScrollBars" (on-off (pjb-frame-vertical-scroll-bars)))
     ("*visualClass"        (or-unset (x-display-visual-class))))
    ("emacs*menu"
     ("*font"              (face-font 'menu))
diff --git a/pl1-keywords.lisp b/pl1-keywords.lisp
index 7570ebe..c195b40 100644
--- a/pl1-keywords.lisp
+++ b/pl1-keywords.lisp
@@ -373,7 +373,7 @@ zerodivide|zdiv


 (defparameter *expanded-keywords*
-  (mapcar (lambda (regexp) (parse-lex-regexp (string-trim "     " regexp)))
+  (mapcar (lambda (regexp) (parse-lex-regexp (cl:string-trim "     " regexp)))
          (split-sequence:split-sequence  #\newline  *pl1-keywords* :remove-empty-subseqs t)))

 ;; (reduce (function append) *expanded-keywords*)
ViewGit