xwem-patches
[Top] [All Lists]

Summary for xwem--main--2.2--patch-2

From: Zajcev Evgeny <lg@xxxxxxxx>
Subject: Summary for xwem--main--2.2--patch-2
Date: Wed, 6 Apr 2005 02:39:55 +0400 (MSD)
Location: lg@xxxxxxxxxxxxxx http://arch.xwem.org/2005/

Revision: xwem--main--2.2--patch-2
Archive: lg@xxxxxxxxxxxxxx
Creator: Zajcev Evgeny <lg@xxxxxxxx>
Date: Wed Apr  6 02:39:40 MSD 2005
Standard-date: 2005-04-05 22:39:40 GMT
Modified-files: extra/xwem-ratanot.el lisp/xwem-edmacro.el
    lisp/xwem-keyboard.el lisp/xwem-special.el
New-patches: dev@xxxxxxxxxxxxxxxx/xwem--dev--2.2--patch-1
    lg@xxxxxxxxxxxxxx/xwem--main--2.2--patch-2
Summary: merge from ckent, special mode fixes, initial ratanot rework
Keywords: ckent, special, edmacro, ratanot

* extra/xwem-ratanot.el: Reworking started.  There will be no special
  major mode for ratanot. ratanot will simple provide minor mode to
  easify way of creating clients related notes.

* lisp/xwem-edmacro.el: Fixes to make edmacro modify key bindings in
  particular keymaps, not only in `xwem-global-map'.

* lisp/xwem-keyboard.el (xwem-read-key-sequence-1): [fix] Keep
  `xwem-event-client' while reading key sequence.

* lisp/xwem-special.el (xwem-manage-emacs-special): [fix] Proper X
  position selection, in case when minibuffer is moved horizontally.

* added directories

    {arch}/xwem/xwem--dev/xwem--dev--2.2
    {arch}/xwem/xwem--dev/xwem--dev--2.2/dev@xxxxxxxxxxxxxxxx
    {arch}/xwem/xwem--dev/xwem--dev--2.2/dev@xxxxxxxxxxxxxxxx/patch-log

* added files

    {arch}/xwem/xwem--dev/xwem--dev--2.2/dev@xxxxxxxxxxxxxxxx/patch-log/patch-1
    {arch}/xwem/xwem--main/xwem--main--2.2/lg@xxxxxxxxxxxxxx/patch-log/patch-2

* modified files

--- orig/extra/xwem-ratanot.el
+++ mod/extra/xwem-ratanot.el
@@ -33,143 +33,163 @@
 ;;; Code:
 
 (require 'xwem-load)
-(require 'xwem-manage)
 
-(defvar xwem-rnt-frame-name "xwem-rnt-frame"
-  "Emacs frame name to be handled by xwem.")
+(defgroup xwem-ratanot nil
+  "Group to customize ratanot."
+  :prefix "xwem-ratanot-"
+  :group 'xwem)
+
+(defcustom xwem-ratanot-file "rnotes.txt"
+  "*File to use for notes."
+  :type 'file
+  :group 'xwem-ratanot)
+
+(defcustom xwem-ratanot-special-display-strategy 'fill
+  "*Strategy to use when poping up special emacs frame."
+  :type '(choice (const :tag "Half screen" half)
+                 (const :tag "Fill current client" fill)
+                 (const :tag "Center" centre))
+  :group 'xwem-ratanot)
+
+(defcustom xwem-ratanot-template
+  '(date "::   " "[ " (name . 24) " ]" "\n\n"
+         "   * ")
+  "Template to insert on new RataNot entry."
+  :type 'list
+  :group 'xwem-ratanot)
+
+(defvar xwem-ratanot-minor-mode nil
+  "Non-nil if ratanot minor mode is enabled.")
+(make-variable-buffer-local 'xwem-ratanot-minor-mode)
 
-(defvar xwem-rnt-keymap
+(defvar xwem-ratanot-minor-mode-string " RataNot"
+  "String to display in modeline, when ratanot minor mode is enabled.")
+
+(defvar xwem-ratanot-keymap
   (let ((map (make-sparse-keymap)))
-    (define-key map (xwem-kbd "C-<button1>") 'xwem-client-imove)
-    (define-key map (xwem-kbd "C-<button2>") 'xwem-client-idestroy)
-    (define-key map (xwem-kbd "C-<button3>") 'xwem-client-iresize)
+    (define-key map (kbd "C-i d") 'xwem-ratanot-insert-date)
+    (define-key map (kbd "C-i n") 'xwem-ratanot-insert-name)
+    (define-key map (kbd "C-i c") 'xwem-ratanot-insert-class)
+    (define-key map (kbd "C-i s") 'xwem-ratanot-insert-size)
+    (define-key map (kbd "C-i m") 'xwem-ratanot-insert-mode)
+    (define-key map (kbd "C-i a") 'xwem-ratanot-insert-application)
+    (define-key map (kbd "C-i i") 'xwem-ratanot-insert-custom-field)
     map)
-  "Keymap for ratanot clients.")
+  "Keymap used when ratanot minor mode is enabled.")
 
 
-(defun xwem-rnt-create-frame (ncl)
-  "Create note XEmacs frame for NCL."
-  (let ((rnt-frame (make-frame (list 'xwem-ratanot-cl ncl
-                                     'border-width 2
-                                     'border-color "blue"
-                                     'initially-unmapped  t
-                                     'name xwem-rnt-frame-name)
-                               (default-x-device))))
-    (raise-frame rnt-frame)
-    ))
-
-(defun xwem-rnt-manage (cl &rest args)
-  "Function to manage rnt CL."
-  (let* ((frame (xwem-misc-find-emacs-frame cl))
-         (srect (make-X-Rect :x 0 :y 0 :width 20 :height 20))
-         (frect (X-Geom-to-X-Rect (xwem-cl-xgeom cl)))
-         (rfcl (and (framep frame) (frame-property frame 'xwem-ratanot-cl))))
-
-    (when (xwem-cl-p rfcl)
-      (xwem-message 'note "ROT-AND-NOTE: manage.")
-
-      (setq srect (X-Geom-to-X-Rect (xwem-cl-xgeom rfcl)))
-
-      ;; Save ratanot-for client and emacs frame
-      (unless (xwem-cl-get-sys-prop cl 'ratanot-for-cl)
-        (xwem-cl-put-sys-prop cl 'ratanot-for-cl rfcl))
-      (unless (xwem-cl-get-sys-prop cl 'ratanot-frame)
-        (xwem-cl-put-sys-prop cl 'ratanot-frame frame))
-
-      (xwem-rnt-refit cl))
-
-;    (xwem-misc-move-outline srect frect 100)
-    (xwem-misc-raise-xwin (xwem-cl-xwin cl))
-    (XMapWindow (xwem-dpy) (xwem-cl-xwin cl))
-
-    ;; Install local keymap
-    (xwem-use-local-map xwem-rnt-keymap cl)
-    ))
-
-(defun xwem-rnt-demanage (cl &rest args)
-  "Function to demanage rnt CL."
-  (xwem-message 'note "ROT-AND-NOTE: demanage.")
-
-  ;; Delete emacs frame
-  (when (frame-live-p (xwem-cl-get-sys-prop cl 'ratanot-frame))
-    (delete-frame (xwem-cl-get-sys-prop cl 'ratanot-frame) t))
-
-  (unless (eq (xwem-cl-state cl) 'destroyed)
-    (XDestroyWindow (xwem-dpy) (xwem-cl-xwin cl)))
-
-  ;; Select ratanot-for-cl
-  (when (xwem-cl-get-sys-prop cl 'ratanot-for-cl)
-    (xwem-message 'note "selecting CL, %S" (xwem-client-name 
(xwem-cl-get-sys-prop cl 'ratanot-for-cl)))
-    (xwem-select-client (xwem-cl-get-sys-prop cl 'ratanot-for-cl)))
-  )
+(defvar xwem-ratanot-last-client nil)
+(defun xwem-ratanot-client ()
+  "Return client."
+  (or xwem-ratanot-last-client
+      (xwem-last-client)))
+
+(defvar xwem-ratanot-fields-alist nil
+  "Alist of fields that can be inserted by ratanot.")
+
+(defvar xwem-ratanot-last-insertion "name")
+
+(defun xwem-ratanot-insert-custom-field (field limit)
+  "Insert FIELD limiting output with LIMIT."
+  (interactive (list (completing-read
+                      (if xwem-ratanot-last-insertion
+                          (format "RataNot field [%s]: "
+                                  xwem-ratanot-last-insertion)
+                        "RataNot field: ")
+                      (mapcar #'(lambda (el)
+                                  (list (symbol-name (car el))))
+                              xwem-ratanot-fields-alist)
+                      nil t nil nil xwem-ratanot-last-insertion)
+                     prefix-arg))
+
+  ;; Save last insterted field
+  (when (stringp field)
+    (setq xwem-ratanot-last-insertion field))
+
+  (let* ((sexp (cdr (assq (or (and (symbolp field) field)
+                              (intern field))
+                          xwem-ratanot-fields-alist)))
+         (rstr (eval sexp)))
+    (unless (stringp rstr)
+      (error 'xwem-error "Invalid RataNot field definition" field))
+    (insert (if (and (numberp limit)
+                     (> (length rstr) limit))
+                (substring rstr 0 limit)
+              rstr))))
+
+(defun xwem-ratanot-insert-template ()
+  "Insert the `xwem-ratanot-template'."
+  (mapc #'(lambda (ten)
+            (if (stringp ten)
+                (insert ten)
+              (xwem-ratanot-insert-custom-field
+               (or (and (consp ten) (car ten))
+                   ten) (and (consp ten) (cdr ten)))))
+        xwem-ratanot-template))
+
+;; Define dedicated commands to insert fields
+(defmacro define-xwem-ratanot-inserter (name doc sexp)
+  "Define new inserter macro for ratanot minor mode."
+  (let ((ifun (intern (format "xwem-ratanot-insert-%S" name))))
+    `(progn
+       (setq xwem-ratanot-fields-alist
+             (put-alist ',name ',sexp xwem-ratanot-fields-alist))
+       (defun ,ifun (limit)
+         ,doc
+         (interactive "P")
+         (xwem-ratanot-insert-custom-field ',name limit)))))
+
+(define-xwem-ratanot-inserter date
+  "Insert current date."
+  (current-time-string))
+
+(define-xwem-ratanot-inserter name
+  "Insert client's name.
+If numeric prefix argument LIMIT is specified, limit output to LIMIT
+characters."
+  (xwem-client-name (xwem-ratanot-client)))
+
+(define-xwem-ratanot-inserter class
+  "Insert client's class."
+  (format "%S" (xwem-cl-wm-class (xwem-ratanot-client))))
+
+(define-xwem-ratanot-inserter size
+  "Insert client's size."
+  (let ((usz (xwem-cl-get-usize (xwem-ratanot-client))))
+    (format "%dx%d" (car usz) (cdr usz))))
+
+(define-xwem-ratanot-inserter uptime
+  "Insert client's uptime."
+  (xwem-cl-get-uptime (xwem-ratanot-client)))
+
+(define-xwem-ratanot-inserter mode
+  "Insert client's major mode (managing mode) name."
+  (symbol-name (xwem-cl-manage-type (xwem-ratanot-client))))
+
+(define-xwem-ratanot-inserter application
+  "Insert client's application name."
+  (or (car (xwem-client-application (xwem-ratanot-client)))
+      "Unknown"))
 
-(defun xwem-rnt-refit (cl &rest args)
-  "Function to refit rnt CL"
-  (xwem-message 'note "ROT-AND-NOTE: refit.")
+
+;; Minor mode
+(defun xwem-ratanot-minor-mode (&optional arg)
+  "Enable or disable ratanot minor mode.
+If prefix ARG is positive number - enable it.
+If prefix ARG is negative number - disable it.
+Otherwise toggle."
+  (interactive "P")
+  ;; TODO: write me
+  )
   
-  (let* ((rfcl (xwem-cl-get-sys-prop cl 'ratanot-for-cl))
-         (rfg (xwem-cl-xgeom rfcl))
-         (clg (xwem-cl-xgeom cl))
-         (tpnt (car (XTranslateCoordinates
-                     (xwem-dpy) (xwem-cl-xwin rfcl) (xwem-rootwin)
-                     (X-Geom-x rfg) (X-Geom-y rfg)))))
-
-    (XReparentWindow (xwem-dpy) (xwem-cl-xwin cl) (xwem-rootwin)
-                     (+ (X-Point-x tpnt) (/ (- (X-Geom-width rfg) 
(X-Geom-width clg)) 2))
-                     (+ (X-Point-y tpnt) (/ (- (X-Geom-height rfg) 
(X-Geom-height clg)) 2)))
-    ))
-
-;(defun xwem-rnt-rotate (ximg)
-;  "Rotate ximg."
-;  (X-Image-)
-;
-;(setq ximg (XGetImage (xwem-dpy) (xwem-cl-xwin (xwem-cl-selected))
-;                      0 0 24 24 X-AllPlanes X-ZPixmap))
-;(setq mcc (let ((str (nth 4 ximg))
-;                (width 24)
-;                ww rltr)
-;            (while (> (length str) 0)
-;            (setq ww (cons (string2->number (substring str 0 2)) ww))
-;            (setq str (substring str 2))
-;            (when (>= (length ww) width)
-;              (setq rltr (cons ww rltr)
-;                    ww nil)))
-;            rltr))
-;
-;      (X-Colormap-lookup-by-id (XDefaultColormap (xwem-dpy)) 3461992025.0)
-;nil
-;(XQueryColors (xwem-dpy) (XDefaultColormap (xwem-dpy)) (list 3461992025.0))
-;(nil)
-;
-;(setq xdata (mapcar (lambda (l)
-;                      (mapconcat  'identity (mapcar 'int->string2 l) ""))
-;                    mcc))
-;()
-;
-;(setq nimg (XCreateImage (xwem-dpy) nil (XDefaultDepth (xwem-dpy)) X-ZPixmap 
0 xdata
-;                         24 24 (X-Dpy-bitmap-scanline-pad (xwem-dpy)) 1))
-;
-;(XImagePut (xwem-dpy) (XDefaultGC (xwem-dpy))
-;           (xwem-frame-xwin (nth 5 xwem-frames-list))
-;           40 40 nimg)
-
 
 (provide 'xwem-ratanot)
 
 ;;;; On-load actions:
-(defun xwem-rnt-on-load ()
-  ;; - Manda entry to manage rotate-and-note Emacs frames
-  (define-xwem-manda 'xwem-special "Manage method for rotate-and-note Emacs 
frames."
-    (define-xwem-class-matcher (concat "^" xwem-rnt-frame-name "$")) 0 t
-    (list 'init nil
-          'manage 'xwem-rnt-manage
-          'demanage 'xwem-rnt-demanage
-          'pop 'xwem-rntl-pop
-          'refit 'xwem-rnt-refit)))
-
-;; - Before init hook
-(if xwem-started
-    (xwem-rnt-on-load)
-  (add-hook 'xwem-before-init-hook 'xwem-rnt-on-load))
+
+;; Register ratanot minor mode
+(add-minor-mode 'xwem-ratanot-minor-mode
+                'xwem-ratanot-minor-mode-string
+                xwem-ratanot-keymap)
 
 ;;; xwem-ratanot.el ends here


--- orig/lisp/xwem-edmacro.el
+++ mod/lisp/xwem-edmacro.el
@@ -85,8 +85,12 @@
                        xwem-edmacro-store-place))
 
         (t
-         ;; redefine key in user macros map
-         (define-key xwem-global-map xwem-edmacro-store-place mac)))
+         ;; Redefine key in user macros map
+         ;; TODO: Do not use `xwem-global-map', use real keymap where
+         ;; key has been bound to. --lg
+         (define-key (or (car xwem-edmacro-store-place)
+                         xwem-global-map)
+           (cdr xwem-edmacro-store-place) mac)))
 
   (setq xwem-edmacro-store-place nil))
 
@@ -115,6 +119,7 @@
   (xwem-kbd-stop-grabbing)
 
   (let ((xwem-cmd (xwem-kbd-get-binding xwem-keys nil t))
+        (xwem-keymap (xwem-lookup-map (xwem-cl-selected) xwem-keys))
         xwem-evs frame)
 
     (setq xwem-evs (cond ((eq xwem-cmd 'xwem-keymacro-play-last)
@@ -123,15 +128,18 @@
                           (or (car xwem-keymacro-macros-stack) []))
 
                          ((vectorp xwem-cmd)
-                          (setq xwem-edmacro-store-place xwem-keys)
+                          (setq xwem-edmacro-store-place
+                                (cons xwem-keymap xwem-keys))
                           xwem-cmd)
 
                          ((and xwem-edmacro-can-edit-unbinded (null xwem-cmd))
-                          (setq xwem-edmacro-store-place xwem-keys)
+                          (setq xwem-edmacro-store-place
+                                (cons xwem-keymap xwem-keys))
                           [])
 
                          (xwem-edmacro-can-edit-nonmacro
-                          (setq xwem-edmacro-store-place xwem-keys)
+                          (setq xwem-edmacro-store-place
+                                (cons xwem-keymap xwem-keys))
                           [])
 
                          (t nil)))


--- orig/lisp/xwem-keyboard.el
+++ mod/lisp/xwem-keyboard.el
@@ -339,7 +339,7 @@
       (setq xev (xwem-next-event))
       (when (setq eev (xwem-xevents->emacs-events (list xev) t))
         (setq xwem-last-xevent xev
-              xwem-event-client (xwem-event-client xev)
+;              xwem-event-client (xwem-event-client xev)
               xwem-last-event (car eev)
               xwem-this-command-keys (vconcat xwem-this-command-keys eev)
               eevs (vconcat eevs eev)


--- orig/lisp/xwem-special.el
+++ mod/lisp/xwem-special.el
@@ -123,6 +123,7 @@
 (defcustom xwem-special-display-buffer-strategy 'half
   "*Strategy to use when display one of `xwem-special-display-buffer-names' 
buffer in special frame."
   :type '(choice (const :tag "Half screen" half)
+                 (const :tag "Fill current client" fill)
                  (const :tag "Center" centre))
   :group 'xwem-special)
 
@@ -159,6 +160,10 @@
         (plist-put special-display-frame-plist 'default-toolbar-visible-p 
xwem-special-toolbar-visible-p))
   (setq special-display-frame-plist
         (plist-put special-display-frame-plist 'wait-for-wm nil))
+
+  ;; Modify `temp-buffer-show-function'
+;  (put 'temp-buffer-show-function 'saved-value temp-buffer-show-function)
+;  (setq temp-buffer-show-function 'special-display-popup-frame)
   )
 
 ;; Functions
@@ -174,10 +179,6 @@
 
     (make-frame props (default-x-device))))
 
-(defun xwem-special-display-popup-frame (buffer &optional args)
-  "Popup special frame with BUFFER."
-  (frame-selected-window (xwem-special-popup-frame buffer)))
-
 ;;;###xwem-autoload
 (defun xwem-special-popup-frame (buf &optional nondedicated-p args)
   "As `special-display-popup-frame', but popup frame for sure.
@@ -252,7 +253,7 @@
     (cond ((eq strategy 'half)
            (setq fgeom
                  (make-X-Geom
-                  :x 0
+                  :x (X-Geom-x (xwem-minib-xgeom xwem-minibuffer))
                   :y (/ (X-Geom-y (xwem-minib-xgeom xwem-minibuffer)) 2)
                   :width (X-Geom-width-with-borders
                           (xwem-minib-cl-xgeom xwem-minibuffer))
@@ -262,10 +263,19 @@
           ((and (eq strategy 'fill)
                 (xwem-cl-alive-p (xwem-cl-selected))
                 (not (eq cl (xwem-cl-selected))))
-           (setq fgeom (copy-X-Geom (xwem-cl-xgeom (xwem-cl-selected))))
-           (setf (X-Geom-x fgeom) 0)
-           (setf (X-Geom-y fgeom) 0)
-           (setf (X-Geom-border-width fgeom) xwem-special-fill-border-width)
+           (setq fgeom
+                 (make-X-Geom
+                  :x xwem-special-fill-border-width
+                  :y xwem-special-fill-border-width
+                  :width (- (X-Geom-width
+                             (xwem-cl-xgeom (xwem-cl-selected)))
+                            xwem-special-fill-border-width
+                            xwem-special-fill-border-width)
+                  :height (- (X-Geom-height
+                              (xwem-cl-xgeom (xwem-cl-selected)))
+                             xwem-special-fill-border-width
+                             xwem-special-fill-border-width)
+                  :border-width nil))
            (setq par-win (xwem-cl-xwin (xwem-cl-selected)))))
 
     ;; Operate on unmapped window
@@ -275,6 +285,8 @@
       (xwem-cl-correct-size-for-size cl fgeom))
     (xwem-cl-apply-xgeom-1 cl)
 
+    ;; Reparent client
+    (xwem-cl-put-sys-prop cl 'special-parent par-win)
     (XReparentWindow (xwem-dpy) win par-win
                      (X-Geom-x (xwem-cl-xgeom cl))
                      (X-Geom-y (xwem-cl-xgeom cl)))
@@ -285,18 +297,21 @@
                             XM-VisibilityChange XM-StructureNotify))
     (X-Win-EventHandler-add-new win 'xwem-special-evhandler)
 
-    ;; Select client
     (xwem-special-select cl)))
 
 (define-xwem-deffered xwem-special-apply-state (cl)
   "Apply CL's state to life."
-  (cond ((eq (xwem-cl-state cl) 'active)
+  (case (xwem-cl-state cl)
+    (active
+     (if (X-Win-equal (xwem-cl-get-sys-prop cl 'special-parent)
+                      (xwem-rootwin))
          (xwem-misc-raise-xwin (xwem-cl-xwin cl))
-         (XMapWindow (xwem-dpy) (xwem-cl-xwin cl)))
-
-        ((eq (xwem-cl-state cl) '(inactive iconify))
-         (XUnmapWindow (xwem-dpy) (xwem-cl-xwin cl))
-         (xwem-special-revert-focus cl))))
+       (XRaiseWindow (xwem-dpy) (xwem-cl-xwin cl)))
+     (XMapWindow (xwem-dpy) (xwem-cl-xwin cl)))
+    
+    ((inactive iconified)
+     (XUnmapWindow (xwem-dpy) (xwem-cl-xwin cl))
+     (xwem-special-revert-focus cl))))
 
 (defun xwem-activate-emacs-special (cl &optional type)
   "Activate method for special emacs frame client CL."




<Prev in Thread] Current Thread [Next in Thread>
  • Summary for xwem--main--2.2--patch-2, Zajcev Evgeny <=