all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* use of symbolic display elements in ruler-mode
@ 2004-03-18 13:14 David PONCE
  2004-03-18 14:27 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: David PONCE @ 2004-03-18 13:14 UTC (permalink / raw)



Hi,

Here is a patch for ruler-mode.el that now uses symbolic display
elements for scrollbar, fringes and margins width.

Please, could someone install the patch for me?
Thanks!

Sincerely,
David

Index: lisp/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.5775
diff -c -r1.5775 ChangeLog
*** lisp/ChangeLog	18 Mar 2004 03:07:38 -0000	1.5775
--- lisp/ChangeLog	18 Mar 2004 12:40:37 -0000
***************
*** 1,3 ****
--- 1,15 ----
+ 2004-03-18  David Ponce  <david@dponce.com>
+ 
+ 	* ruler-mode.el (ruler-mode-header-line-format-old): Don't
+ 	`make-variable-buffer-local'.
+ 	(ruler-mode-ruler-function): Doc fix.
+ 	(ruler-mode-header-line-format): Simplify value.  Doc fix.
+ 	(ruler-mode): Use `make-local-variable' and `kill-local-variable'
+ 	to save/restore a previous header line format.
+ 	(ruler-mode-space): Don't depend on a numeric WIDTH value.
+ 	(ruler-mode-ruler): Use symbolic display elements for scrollbar,
+ 	fringes and margins width.
+ 
  2004-03-17  Luc Teirlinck  <teirllm@auburn.edu>
  
  	* simple.el (clone-buffer): Doc fix.
Index: lisp/ruler-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ruler-mode.el,v
retrieving revision 1.19
diff -c -r1.19 ruler-mode.el
*** lisp/ruler-mode.el	15 Mar 2004 08:39:06 -0000	1.19
--- lisp/ruler-mode.el	18 Mar 2004 12:40:37 -0000
***************
*** 1,6 ****
  ;;; ruler-mode.el --- display a ruler in the header line
  
! ;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  
  ;; Author: David Ponce <david@dponce.com>
  ;; Maintainer: David Ponce <david@dponce.com>
--- 1,6 ----
  ;;; ruler-mode.el --- display a ruler in the header line
  
! ;; Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  
  ;; Author: David Ponce <david@dponce.com>
  ;; Maintainer: David Ponce <david@dponce.com>
***************
*** 95,101 ****
  ;; important to use the same font family and size for ruler and text
  ;; areas.
  ;;
! ;; You can override the ruler format by defining an appropriate 
  ;; function as the buffer-local value of `ruler-mode-ruler-function'.
  
  ;; Installation
--- 95,101 ----
  ;; important to use the same font family and size for ruler and text
  ;; areas.
  ;;
! ;; You can override the ruler format by defining an appropriate
  ;; function as the buffer-local value of `ruler-mode-ruler-function'.
  
  ;; Installation
***************
*** 531,549 ****
  
  (defvar ruler-mode-header-line-format-old nil
    "Hold previous value of `header-line-format'.")
- (make-variable-buffer-local 'ruler-mode-header-line-format-old)
  
  (defvar ruler-mode-ruler-function nil
!   "If non-nil, function to call to return ruler string.
  This variable is expected to be made buffer-local by modes.")
  
  (defconst ruler-mode-header-line-format
!   '(:eval (funcall (if ruler-mode-ruler-function
! 		       ruler-mode-ruler-function
! 		     'ruler-mode-ruler)))
    "`header-line-format' used in ruler mode.
! If the non-nil value for ruler-mode-ruler-function is given, use it.
! Else use `ruler-mode-ruler' is used as default value.")
  
  ;;;###autoload
  (define-minor-mode ruler-mode
--- 531,546 ----
  
  (defvar ruler-mode-header-line-format-old nil
    "Hold previous value of `header-line-format'.")
  
  (defvar ruler-mode-ruler-function nil
!   "If non-nil, function to call to return ruler header line format.
  This variable is expected to be made buffer-local by modes.")
  
  (defconst ruler-mode-header-line-format
!   '(:eval (funcall (or ruler-mode-ruler-function 'ruler-mode-ruler)))
    "`header-line-format' used in ruler mode.
! If `ruler-mode-ruler-function' is non-nil, call it to compute the
! ruler value, else use `ruler-mode-ruler'.")
  
  ;;;###autoload
  (define-minor-mode ruler-mode
***************
*** 556,573 ****
          ;; When `ruler-mode' is on save previous header line format
          ;; and install the ruler header line format.
          (when (local-variable-p 'header-line-format)
!           (setq ruler-mode-header-line-format-old header-line-format))
          (setq header-line-format ruler-mode-header-line-format)
!         (add-hook 'post-command-hook    ; add local hook
!                   #'force-mode-line-update nil t))
      ;; When `ruler-mode' is off restore previous header line format if
      ;; the current one is the ruler header line format.
      (when (eq header-line-format ruler-mode-header-line-format)
        (kill-local-variable 'header-line-format)
        (when (local-variable-p 'ruler-mode-header-line-format-old)
!         (setq header-line-format ruler-mode-header-line-format-old)))
!     (remove-hook 'post-command-hook     ; remove local hook
!                  #'force-mode-line-update t)))
  \f
  ;; Add ruler-mode to the minor mode menu in the mode line
  (define-key mode-line-mode-menu [ruler-mode]
--- 553,570 ----
          ;; When `ruler-mode' is on save previous header line format
          ;; and install the ruler header line format.
          (when (local-variable-p 'header-line-format)
!           (set (make-local-variable 'ruler-mode-header-line-format-old)
!                header-line-format))
          (setq header-line-format ruler-mode-header-line-format)
!         (add-hook 'post-command-hook 'force-mode-line-update nil t))
      ;; When `ruler-mode' is off restore previous header line format if
      ;; the current one is the ruler header line format.
      (when (eq header-line-format ruler-mode-header-line-format)
        (kill-local-variable 'header-line-format)
        (when (local-variable-p 'ruler-mode-header-line-format-old)
!         (setq header-line-format ruler-mode-header-line-format-old)
!         (kill-local-variable 'ruler-mode-header-line-format-old)))
!     (remove-hook 'post-command-hook 'force-mode-line-update t)))
  \f
  ;; Add ruler-mode to the minor mode menu in the mode line
  (define-key mode-line-mode-menu [ruler-mode]
***************
*** 621,753 ****
  (defsubst ruler-mode-space (width &rest props)
    "Return a single space string of WIDTH times the normal character width.
  Optional argument PROPS specifies other text properties to apply."
!   (if (> width 0)
!       (apply 'propertize " " 'display (list 'space :width width) props)
!     ""))
  \f
  (defun ruler-mode-ruler ()
!   "Return a string ruler."
!   (when ruler-mode
!     (let* ((w     (window-width))
!            (m     (window-margins))
!            (lsb   (scroll-bar-columns 'left))
!            (lf    (fringe-columns 'left t))
!            (lm    (or (car m) 0))
!            (rsb   (scroll-bar-columns 'right))
!            (rf    (fringe-columns 'right t))
!            (rm    (or (cdr m) 0))
!            (ruler (make-string w ruler-mode-basic-graduation-char))
!            (i     0)
!            (j     (window-hscroll))
!            k c l1 l2 r2 r1 h1 h2 f1 f2)
! 
!       ;; Setup the default properties.
!       (put-text-property 0 w 'face 'ruler-mode-default-face ruler)
!       (put-text-property 0 w
!                          'help-echo
!                          (cond
!                           (ruler-mode-show-tab-stops
!                            ruler-mode-ruler-help-echo-when-tab-stops)
!                           (goal-column
!                            ruler-mode-ruler-help-echo-when-goal-column)
!                           (t
!                            ruler-mode-ruler-help-echo))
!                          ruler)
!       ;; Setup the local map.
!       (put-text-property 0 w 'local-map ruler-mode-map ruler)
! 
!       ;; Setup the active area.
!       (while (< i w)
!         ;; Graduations.
!         (cond
!          ;; Show a number graduation.
!          ((= (mod j 10) 0)
!           (setq c (number-to-string (/ j 10))
!                 m (length c)
!                 k i)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-column-number-face
!            ruler)
!           (while (and (> m 0) (>= k 0))
!             (aset ruler k (aref c (setq m (1- m))))
!             (setq k (1- k))))
!          ;; Show an intermediate graduation.
!          ((= (mod j 5) 0)
!           (aset ruler i ruler-mode-inter-graduation-char)))
!         ;; Special columns.
!         (cond
!          ;; Show the `current-column' marker.
!          ((= j (current-column))
!           (aset ruler i ruler-mode-current-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-current-column-face
!            ruler))
!          ;; Show the `goal-column' marker.
!          ((and goal-column (= j goal-column))
!           (aset ruler i ruler-mode-goal-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-goal-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-goal-column-help-echo
!            ruler))
!          ;; Show the `comment-column' marker.
!          ((= j comment-column)
!           (aset ruler i ruler-mode-comment-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-comment-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-comment-column-help-echo
!            ruler))
!          ;; Show the `fill-column' marker.
!          ((= j fill-column)
!           (aset ruler i ruler-mode-fill-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-fill-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-fill-column-help-echo
!            ruler))
!          ;; Show the `tab-stop-list' markers.
!          ((and ruler-mode-show-tab-stops (member j tab-stop-list))
!           (aset ruler i ruler-mode-tab-stop-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-tab-stop-face
!            ruler)))
!         (setq i (1+ i)
!               j (1+ j)))
! 
!       ;; Highlight the fringes and margins.
!       (if (nth 2 (window-fringes))
!           ;; fringes outside margins.
!           (setq l1 lf
!                 l2 lm
!                 r2 rm
!                 r1 rf
!                 h1 ruler-mode-fringe-help-echo
!                 h2 ruler-mode-margin-help-echo
!                 f1 'ruler-mode-fringes-face
!                 f2 'ruler-mode-margins-face)
!         ;; fringes inside margins.
!         (setq l1 lm
!               l2 lf
!               r2 rf
!               r1 rm
!               h1 ruler-mode-margin-help-echo
!               h2 ruler-mode-fringe-help-echo
!               f1 'ruler-mode-margins-face
!               f2 'ruler-mode-fringes-face))
!       ;; Return the ruler propertized string.  Using list here,
!       ;; instead of concat visually separate the different areas.
!       (list
!        (ruler-mode-space lsb 'face 'ruler-mode-pad-face)
!        (ruler-mode-space l1 'face f1 'help-echo (format h1 "Left" l1))
!        (ruler-mode-space l2 'face f2 'help-echo (format h2 "Left" l2))
!        ruler
!        (ruler-mode-space r2 'face f2 'help-echo (format h2 "Right" r2))
!        (ruler-mode-space r1 'face f1 'help-echo (format h1 "Right" r1))
!        (ruler-mode-space rsb 'face 'ruler-mode-pad-face)))))
  
  (provide 'ruler-mode)
  
--- 618,738 ----
  (defsubst ruler-mode-space (width &rest props)
    "Return a single space string of WIDTH times the normal character width.
  Optional argument PROPS specifies other text properties to apply."
!   (apply 'propertize " " 'display (list 'space :width width) props))
  \f
  (defun ruler-mode-ruler ()
!   "Compute and return an header line ruler."
!   (let* ((w (window-width))
!          (m (window-margins))
!          (f (window-fringes))
!          (i 0)
!          (j (window-hscroll))
!          ;; Setup the scrollbar, fringes, and margins areas.
!          (lf (ruler-mode-space
!               'left-fringe
!               'face 'ruler-mode-fringes-face
!               'help-echo (format ruler-mode-fringe-help-echo
!                                  "Left" (or (car f) 0))))
!          (rf (ruler-mode-space
!               'right-fringe
!               'face 'ruler-mode-fringes-face
!               'help-echo (format ruler-mode-fringe-help-echo
!                                  "Right" (or (cadr f) 0))))
!          (lm (ruler-mode-space
!               'left-margin
!               'face 'ruler-mode-margins-face
!               'help-echo (format ruler-mode-margin-help-echo
!                                  "Left" (or (car m) 0))))
!          (rm (ruler-mode-space
!               'right-margin
!               'face 'ruler-mode-margins-face
!               'help-echo (format ruler-mode-margin-help-echo
!                                  "Right" (or (cdr m) 0))))
!          (lsb (ruler-mode-space '(scroll-bar . left)
!                                 'face 'ruler-mode-pad-face))
!          (rsb (ruler-mode-space '(scroll-bar . right)
!                                 'face 'ruler-mode-pad-face))
!           ;; Create an "clean" ruler.
!          (ruler
!           (propertize
!            (make-string w ruler-mode-basic-graduation-char)
!            'face 'ruler-mode-default-face
!            'local-map ruler-mode-map
!            'help-echo (cond
!                        (ruler-mode-show-tab-stops
!                         ruler-mode-ruler-help-echo-when-tab-stops)
!                        (goal-column
!                         ruler-mode-ruler-help-echo-when-goal-column)
!                        (ruler-mode-ruler-help-echo))))
!          k c)
!     ;; Setup the active area.
!     (while (< i w)
!       ;; Graduations.
!       (cond
!        ;; Show a number graduation.
!        ((= (mod j 10) 0)
!         (setq c (number-to-string (/ j 10))
!               m (length c)
!               k i)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-column-number-face
!          ruler)
!         (while (and (> m 0) (>= k 0))
!           (aset ruler k (aref c (setq m (1- m))))
!           (setq k (1- k))))
!        ;; Show an intermediate graduation.
!        ((= (mod j 5) 0)
!         (aset ruler i ruler-mode-inter-graduation-char)))
!       ;; Special columns.
!       (cond
!        ;; Show the `current-column' marker.
!        ((= j (current-column))
!         (aset ruler i ruler-mode-current-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-current-column-face

!          ruler))
!        ;; Show the `goal-column' marker.
!        ((and goal-column (= j goal-column))
!         (aset ruler i ruler-mode-goal-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-goal-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-goal-column-help-echo
!          ruler))
!        ;; Show the `comment-column' marker.
!        ((= j comment-column)
!         (aset ruler i ruler-mode-comment-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-comment-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-comment-column-help-echo
!          ruler))
!        ;; Show the `fill-column' marker.
!        ((= j fill-column)
!         (aset ruler i ruler-mode-fill-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-fill-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-fill-column-help-echo
!          ruler))
!        ;; Show the `tab-stop-list' markers.
!        ((and ruler-mode-show-tab-stops (member j tab-stop-list))
!         (aset ruler i ruler-mode-tab-stop-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-tab-stop-face
!          ruler)))
!       (setq i (1+ i)
!             j (1+ j)))
!     ;; Return the ruler propertized string.  Using list here,
!     ;; instead of concat visually separate the different areas.
!     (if (nth 2 (window-fringes))
!         ;; fringes outside margins.
!         (list lsb lf lm ruler rm rf rsb)
!       ;; fringes inside margins.
!       (list lsb lm lf ruler rf rm rsb))))
  
  (provide 'ruler-mode)
  

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: use of symbolic display elements in ruler-mode
  2004-03-18 13:14 use of symbolic display elements in ruler-mode David PONCE
@ 2004-03-18 14:27 ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2004-03-18 14:27 UTC (permalink / raw)
  Cc: emacs-devel

>  (defvar ruler-mode-ruler-function nil
> -  "If non-nil, function to call to return ruler string.
> +  "If non-nil, function to call to return ruler header line format.
>  This variable is expected to be made buffer-local by modes.")
>  (defconst ruler-mode-header-line-format
> -  '(:eval (funcall (if ruler-mode-ruler-function
> -		       ruler-mode-ruler-function
> -		     'ruler-mode-ruler)))
> +  '(:eval (funcall (or ruler-mode-ruler-function 'ruler-mode-ruler)))
>    "`header-line-format' used in ruler mode.
> -If the non-nil value for ruler-mode-ruler-function is given, use it.
> -Else use `ruler-mode-ruler' is used as default value.")
> +If `ruler-mode-ruler-function' is non-nil, call it to compute the
> +ruler value, else use `ruler-mode-ruler'.")

Why not just:

(defvar ruler-mode-ruler-function 'ruler-mode-ruler
  "Function to call to return ruler string.")
(defconst ruler-mode-header-line-format
  '(:eval (funcall ruler-mode-ruler-function))
   "`header-line-format' used in ruler mode.")


-- Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: use of symbolic display elements in ruler-mode
@ 2004-03-18 14:52 David PONCE
  2004-03-19  1:50 ` Kim F. Storm
  0 siblings, 1 reply; 7+ messages in thread
From: David PONCE @ 2004-03-18 14:52 UTC (permalink / raw)
  Cc: emacs-devel

Hi Stefan,

> Why not just:
> 
> (defvar ruler-mode-ruler-function 'ruler-mode-ruler
>   "Function to call to return ruler string.")
> (defconst ruler-mode-header-line-format
>   '(:eval (funcall ruler-mode-ruler-function))
>    "`header-line-format' used in ruler mode.")

Of course!  Here is a new patch.

Thanks!
David

Index: lisp/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.5775
diff -c -r1.5775 ChangeLog
*** lisp/ChangeLog	18 Mar 2004 03:07:38 -0000	1.5775
--- lisp/ChangeLog	18 Mar 2004 14:49:57 -0000
***************
*** 1,3 ****
--- 1,16 ----
+ 2004-03-18  David Ponce  <david@dponce.com>
+ 
+ 	* ruler-mode.el (ruler-mode-header-line-format-old): Don't
+ 	`make-variable-buffer-local'.
+ 	(ruler-mode-ruler-function): Default to `ruler-mode-ruler'.
+ 	(ruler-mode-header-line-format): Simply funcall the above.
+ 	(ruler-mode): Use `make-local-variable' and `kill-local-variable'
+ 	to save/restore a previous header line format.
+ 	(ruler-mode-space): Don't depend on a numeric WIDTH value.
+ 	(ruler-mode-ruler): Use symbolic display elements for scrollbar,
+ 	fringes and margins width.
+ 	(ruler-mode-ruler-function): Default to ruler-mode-ruler
+ 
  2004-03-17  Luc Teirlinck  <teirllm@auburn.edu>
  
  	* simple.el (clone-buffer): Doc fix.
Index: lisp/ruler-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ruler-mode.el,v
retrieving revision 1.19
diff -c -r1.19 ruler-mode.el
*** lisp/ruler-mode.el	15 Mar 2004 08:39:06 -0000	1.19
--- lisp/ruler-mode.el	18 Mar 2004 14:49:57 -0000
***************
*** 1,6 ****
  ;;; ruler-mode.el --- display a ruler in the header line
  
! ;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  
  ;; Author: David Ponce <david@dponce.com>
  ;; Maintainer: David Ponce <david@dponce.com>
--- 1,6 ----
  ;;; ruler-mode.el --- display a ruler in the header line
  
! ;; Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  
  ;; Author: David Ponce <david@dponce.com>
  ;; Maintainer: David Ponce <david@dponce.com>
***************
*** 95,101 ****
  ;; important to use the same font family and size for ruler and text
  ;; areas.
  ;;
! ;; You can override the ruler format by defining an appropriate 
  ;; function as the buffer-local value of `ruler-mode-ruler-function'.
  
  ;; Installation
--- 95,101 ----
  ;; important to use the same font family and size for ruler and text
  ;; areas.
  ;;
! ;; You can override the ruler format by defining an appropriate
  ;; function as the buffer-local value of `ruler-mode-ruler-function'.
  
  ;; Installation
***************
*** 531,549 ****
  
  (defvar ruler-mode-header-line-format-old nil
    "Hold previous value of `header-line-format'.")
- (make-variable-buffer-local 'ruler-mode-header-line-format-old)
  
! (defvar ruler-mode-ruler-function nil
!   "If non-nil, function to call to return ruler string.
  This variable is expected to be made buffer-local by modes.")
  
  (defconst ruler-mode-header-line-format
!   '(:eval (funcall (if ruler-mode-ruler-function
! 		       ruler-mode-ruler-function
! 		     'ruler-mode-ruler)))
    "`header-line-format' used in ruler mode.
! If the non-nil value for ruler-mode-ruler-function is given, use it.
! Else use `ruler-mode-ruler' is used as default value.")
  
  ;;;###autoload
  (define-minor-mode ruler-mode
--- 531,545 ----
  
  (defvar ruler-mode-header-line-format-old nil
    "Hold previous value of `header-line-format'.")
  
! (defvar ruler-mode-ruler-function 'ruler-mode-ruler
!   "Function to call to return ruler header line format.
  This variable is expected to be made buffer-local by modes.")
  
  (defconst ruler-mode-header-line-format
!   '(:eval (funcall ruler-mode-ruler-function))
    "`header-line-format' used in ruler mode.
! Call `ruler-mode-ruler-function' to compute the ruler value.")
  
  ;;;###autoload
  (define-minor-mode ruler-mode
***************
*** 556,573 ****
          ;; When `ruler-mode' is on save previous header line format
          ;; and install the ruler header line format.
          (when (local-variable-p 'header-line-format)
!           (setq ruler-mode-header-line-format-old header-line-format))
          (setq header-line-format ruler-mode-header-line-format)
!         (add-hook 'post-command-hook    ; add local hook
!                   #'force-mode-line-update nil t))
      ;; When `ruler-mode' is off restore previous header line format if
      ;; the current one is the ruler header line format.
      (when (eq header-line-format ruler-mode-header-line-format)
        (kill-local-variable 'header-line-format)
        (when (local-variable-p 'ruler-mode-header-line-format-old)
!         (setq header-line-format ruler-mode-header-line-format-old)))
!     (remove-hook 'post-command-hook     ; remove local hook
!                  #'force-mode-line-update t)))
  \f
  ;; Add ruler-mode to the minor mode menu in the mode line
  (define-key mode-line-mode-menu [ruler-mode]
--- 552,569 ----
          ;; When `ruler-mode' is on save previous header line format
          ;; and install the ruler header line format.
          (when (local-variable-p 'header-line-format)
!           (set (make-local-variable 'ruler-mode-header-line-format-old)
!                header-line-format))
          (setq header-line-format ruler-mode-header-line-format)
!         (add-hook 'post-command-hook 'force-mode-line-update nil t))
      ;; When `ruler-mode' is off restore previous header line format if
      ;; the current one is the ruler header line format.
      (when (eq header-line-format ruler-mode-header-line-format)
        (kill-local-variable 'header-line-format)
        (when (local-variable-p 'ruler-mode-header-line-format-old)
!         (setq header-line-format ruler-mode-header-line-format-old)
!         (kill-local-variable 'ruler-mode-header-line-format-old)))
!     (remove-hook 'post-command-hook 'force-mode-line-update t)))
  \f
  ;; Add ruler-mode to the minor mode menu in the mode line
  (define-key mode-line-mode-menu [ruler-mode]
***************
*** 621,753 ****
  (defsubst ruler-mode-space (width &rest props)
    "Return a single space string of WIDTH times the normal character width.
  Optional argument PROPS specifies other text properties to apply."
!   (if (> width 0)
!       (apply 'propertize " " 'display (list 'space :width width) props)
!     ""))
  \f
  (defun ruler-mode-ruler ()
!   "Return a string ruler."
!   (when ruler-mode
!     (let* ((w     (window-width))
!            (m     (window-margins))
!            (lsb   (scroll-bar-columns 'left))
!            (lf    (fringe-columns 'left t))
!            (lm    (or (car m) 0))
!            (rsb   (scroll-bar-columns 'right))
!            (rf    (fringe-columns 'right t))
!            (rm    (or (cdr m) 0))
!            (ruler (make-string w ruler-mode-basic-graduation-char))
!            (i     0)
!            (j     (window-hscroll))
!            k c l1 l2 r2 r1 h1 h2 f1 f2)
! 
!       ;; Setup the default properties.
!       (put-text-property 0 w 'face 'ruler-mode-default-face ruler)
!       (put-text-property 0 w
!                          'help-echo
!                          (cond
!                           (ruler-mode-show-tab-stops
!                            ruler-mode-ruler-help-echo-when-tab-stops)
!                           (goal-column
!                            ruler-mode-ruler-help-echo-when-goal-column)
!                           (t
!                            ruler-mode-ruler-help-echo))
!                          ruler)
!       ;; Setup the local map.
!       (put-text-property 0 w 'local-map ruler-mode-map ruler)
! 
!       ;; Setup the active area.
!       (while (< i w)
!         ;; Graduations.
!         (cond
!          ;; Show a number graduation.
!          ((= (mod j 10) 0)
!           (setq c (number-to-string (/ j 10))
!                 m (length c)
!                 k i)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-column-number-face
!            ruler)
!           (while (and (> m 0) (>= k 0))
!             (aset ruler k (aref c (setq m (1- m))))
!             (setq k (1- k))))
!          ;; Show an intermediate graduation.
!          ((= (mod j 5) 0)
!           (aset ruler i ruler-mode-inter-graduation-char)))
!         ;; Special columns.
!         (cond
!          ;; Show the `current-column' marker.
!          ((= j (current-column))
!           (aset ruler i ruler-mode-current-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-current-column-face
!            ruler))
!          ;; Show the `goal-column' marker.
!          ((and goal-column (= j goal-column))
!           (aset ruler i ruler-mode-goal-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-goal-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-goal-column-help-echo
!            ruler))
!          ;; Show the `comment-column' marker.
!          ((= j comment-column)
!           (aset ruler i ruler-mode-comment-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-comment-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-comment-column-help-echo
!            ruler))
!          ;; Show the `fill-column' marker.
!          ((= j fill-column)
!           (aset ruler i ruler-mode-fill-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-fill-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-fill-column-help-echo
!            ruler))
!          ;; Show the `tab-stop-list' markers.
!          ((and ruler-mode-show-tab-stops (member j tab-stop-list))
!           (aset ruler i ruler-mode-tab-stop-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-tab-stop-face
!            ruler)))
!         (setq i (1+ i)
!               j (1+ j)))
! 
!       ;; Highlight the fringes and margins.
!       (if (nth 2 (window-fringes))
!           ;; fringes outside margins.
!           (setq l1 lf
!                 l2 lm
!                 r2 rm
!                 r1 rf
!                 h1 ruler-mode-fringe-help-echo
!                 h2 ruler-mode-margin-help-echo
!                 f1 'ruler-mode-fringes-face
!                 f2 'ruler-mode-margins-face)
!         ;; fringes inside margins.
!         (setq l1 lm
!               l2 lf
!               r2 rf
!               r1 rm
!               h1 ruler-mode-margin-help-echo
!               h2 ruler-mode-fringe-help-echo
!               f1 'ruler-mode-margins-face
!               f2 'ruler-mode-fringes-face))
!       ;; Return the ruler propertized string.  Using list here,
!       ;; instead of concat visually separate the different areas.
!       (list
!        (ruler-mode-space lsb 'face 'ruler-mode-pad-face)
!        (ruler-mode-space l1 'face f1 'help-echo (format h1 "Left" l1))
!        (ruler-mode-space l2 'face f2 'help-echo (format h2 "Left" l2))
!        ruler
!        (ruler-mode-space r2 'face f2 'help-echo (format h2 "Right" r2))
!        (ruler-mode-space r1 'face f1 'help-echo (format h1 "Right" r1))
!        (ruler-mode-space rsb 'face 'ruler-mode-pad-face)))))
  
  (provide 'ruler-mode)
  
--- 617,737 ----
  (defsubst ruler-mode-space (width &rest props)
    "Return a single space string of WIDTH times the normal character width.
  Optional argument PROPS specifies other text properties to apply."
!   (apply 'propertize " " 'display (list 'space :width width) props))
  \f
  (defun ruler-mode-ruler ()
!   "Compute and return an header line ruler."
!   (let* ((w (window-width))
!          (m (window-margins))
!          (f (window-fringes))
!          (i 0)
!          (j (window-hscroll))
!          ;; Setup the scrollbar, fringes, and margins areas.
!          (lf (ruler-mode-space
!               'left-fringe
!               'face 'ruler-mode-fringes-face
!               'help-echo (format ruler-mode-fringe-help-echo
!                                  "Left" (or (car f) 0))))
!          (rf (ruler-mode-space
!               'right-fringe
!               'face 'ruler-mode-fringes-face
!               'help-echo (format ruler-mode-fringe-help-echo
!                                  "Right" (or (cadr f) 0))))
!          (lm (ruler-mode-space
!               'left-margin
!               'face 'ruler-mode-margins-face
!               'help-echo (format ruler-mode-margin-help-echo
!                                  "Left" (or (car m) 0))))
!          (rm (ruler-mode-space
!               'right-margin
!               'face 'ruler-mode-margins-face
!               'help-echo (format ruler-mode-margin-help-echo
!                                  "Right" (or (cdr m) 0))))
!          (lsb (ruler-mode-space '(scroll-bar . left)
!                                 'face 'ruler-mode-pad-face))
!          (rsb (ruler-mode-space '(scroll-bar . right)
!                                 'face 'ruler-mode-pad-face))
!           ;; Create an "clean" ruler.
!          (ruler
!           (propertize
!            (make-string w ruler-mode-basic-graduation-char)
!            'face 'ruler-mode-default-face
!            'local-map ruler-mode-map
!            'help-echo (cond
!                        (ruler-mode-show-tab-stops
!                         ruler-mode-ruler-help-echo-when-tab-stops)
!                        (goal-column
!                         ruler-mode-ruler-help-echo-when-goal-column)
!                        (ruler-mode-ruler-help-echo))))
!          k c)
!     ;; Setup the active area.
!     (while (< i w)
!       ;; Graduations.
!       (cond
!        ;; Show a number graduation.
!        ((= (mod j 10) 0)
!         (setq c (number-to-string (/ j 10))
!               m (length c)
!               k i)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-column-number-face
!          ruler)
!         (while (and (> m 0) (>= k 0))
!           (aset ruler k (aref c (setq m (1- m))))
!           (setq k (1- k))))
!        ;; Show an intermediate graduation.
!        ((= (mod j 5) 0)
!         (aset ruler i ruler-mode-inter-graduation-char)))
!       ;; Special columns.
!       (cond
!        ;; Show the `current-column' marker.
!        ((= j (current-column))
!         (aset ruler i ruler-mode-current-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-current-column-face
!          ruler))
!        ;; Show the `goal-column' marker.
!        ((and goal-column (= j goal-column))
!         (aset ruler i ruler-mode-goal-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-goal-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-goal-column-help-echo
!          ruler))
!        ;; Show the `comment-column' marker.
!        ((= j comment-column)
!         (aset ruler i ruler-mode-comment-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-comment-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-comment-column-help-echo
!          ruler))
!        ;; Show the `fill-column' marker.
!        ((= j fill-column)
!         (aset ruler i ruler-mode-fill-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-fill-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-fill-column-help-echo
!          ruler))
!        ;; Show the `tab-stop-list' markers.
!        ((and ruler-mode-show-tab-stops (member j tab-stop-list))
!         (aset ruler i ruler-mode-tab-stop-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-tab-stop-face
!          ruler)))
!       (setq i (1+ i)
!             j (1+ j)))
!     ;; Return the ruler propertized string.  Using list here,
!     ;; instead of concat visually separate the different areas.
!     (if (nth 2 (window-fringes))
!         ;; fringes outside margins.
!         (list lsb lf lm ruler rm rf rsb)
!       ;; fringes inside margins.
!       (list lsb lm lf ruler rf rm rsb))))
  
  (provide 'ruler-mode)
  

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: use of symbolic display elements in ruler-mode
  2004-03-18 14:52 David PONCE
@ 2004-03-19  1:50 ` Kim F. Storm
  0 siblings, 0 replies; 7+ messages in thread
From: Kim F. Storm @ 2004-03-19  1:50 UTC (permalink / raw)
  Cc: monnier, emacs-devel

David PONCE <david.ponce@wanadoo.fr> writes:

> Hi Stefan,
> 
> > Why not just:
> > 
> > (defvar ruler-mode-ruler-function 'ruler-mode-ruler
> >   "Function to call to return ruler string.")
> > (defconst ruler-mode-header-line-format
> >   '(:eval (funcall ruler-mode-ruler-function))
> >    "`header-line-format' used in ruler mode.")
> 
> Of course!  Here is a new patch.

I just installed some changes to the :align-to and :width space
display properties.  And added support for non-window systems.

Specifically, (scroll-bar . x) and (*-fringe . x) no longer exists.
Instead, you have to include scroll-bar and *-fringe in the
proper spots yourself.

Note that you can include nil in the header-line-format list,
as long as the first element of the list is a string (just put ""
there).

Something like:

   Replace lsb and rsb by:

          (sb (ruler-mode-space 'scroll-bar
                                 'face 'ruler-mode-pad-face))

   and use

     (if (nth 2 (window-fringes))
         ;; fringes outside margins.
         (list "" (and (eq scroll-bar-mode 'left) sb) lf lm
               ruler rm rf (and (eq scroll-bar-mode 'right) sb))
       ;; fringes inside margins.
       (list "" (and (eq scroll-bar-mode 'left) sb) lm lf 
             ruler rf rm (and (eq scroll-bar-mode 'right) sb)))))


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: use of symbolic display elements in ruler-mode
@ 2004-03-19  9:51 David PONCE
  2004-03-19 14:20 ` Kim F. Storm
  0 siblings, 1 reply; 7+ messages in thread
From: David PONCE @ 2004-03-19  9:51 UTC (permalink / raw)
  Cc: emacs-devel

Hi Kim,

> I just installed some changes to the :align-to and :width space
> display properties.  And added support for non-window systems.
> 
> Specifically, (scroll-bar . x) and (*-fringe . x) no longer exists.
> Instead, you have to include scroll-bar and *-fringe in the
> proper spots yourself.

Following is a new patch that take into account those changes.

> Note that you can include nil in the header-line-format list,
> as long as the first element of the list is a string (just put ""
> there).
[...]

That's a good thing to know ;-)

Thanks!
David

P.S.: Please, could someone, who has CVS write access, install
         the patch for me?  Thanks!

Index: lisp/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.5776
diff -c -r1.5776 ChangeLog
*** lisp/ChangeLog	19 Mar 2004 00:21:10 -0000	1.5776
--- lisp/ChangeLog	19 Mar 2004 09:45:05 -0000
***************
*** 1,3 ****
--- 1,16 ----
+ 2004-03-19  David Ponce  <david@dponce.com>
+ 
+ 	* ruler-mode.el (ruler-mode-header-line-format-old): Don't
+ 	`make-variable-buffer-local'.
+ 	(ruler-mode-ruler-function): Default to `ruler-mode-ruler'.
+ 	(ruler-mode-header-line-format): Simply funcall the above.
+ 	(ruler-mode): Use `make-local-variable' and `kill-local-variable'
+ 	to save/restore a previous header line format.
+ 	(ruler-mode-space): Don't depend on a numeric WIDTH value.
+ 	(ruler-mode-ruler): Use symbolic display elements for scrollbar,
+ 	fringes and margins width.
+ 	(ruler-mode-ruler-function): Default to ruler-mode-ruler
+ 
  2004-03-19  Kim F. Storm  <storm@cua.dk>
  
  	* progmodes/compile.el (compilation-start): Always set
Index: lisp/ruler-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ruler-mode.el,v
retrieving revision 1.19
diff -c -r1.19 ruler-mode.el
*** lisp/ruler-mode.el	15 Mar 2004 08:39:06 -0000	1.19
--- lisp/ruler-mode.el	19 Mar 2004 09:45:05 -0000
***************
*** 1,6 ****
  ;;; ruler-mode.el --- display a ruler in the header line
  
! ;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  
  ;; Author: David Ponce <david@dponce.com>
  ;; Maintainer: David Ponce <david@dponce.com>
--- 1,6 ----
  ;;; ruler-mode.el --- display a ruler in the header line
  
! ;; Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
  
  ;; Author: David Ponce <david@dponce.com>
  ;; Maintainer: David Ponce <david@dponce.com>
***************
*** 95,101 ****
  ;; important to use the same font family and size for ruler and text
  ;; areas.
  ;;
! ;; You can override the ruler format by defining an appropriate 
  ;; function as the buffer-local value of `ruler-mode-ruler-function'.
  
  ;; Installation
--- 95,101 ----
  ;; important to use the same font family and size for ruler and text
  ;; areas.
  ;;
! ;; You can override the ruler format by defining an appropriate
  ;; function as the buffer-local value of `ruler-mode-ruler-function'.
  
  ;; Installation
***************
*** 531,549 ****
  
  (defvar ruler-mode-header-line-format-old nil
    "Hold previous value of `header-line-format'.")
- (make-variable-buffer-local 'ruler-mode-header-line-format-old)
  
! (defvar ruler-mode-ruler-function nil
!   "If non-nil, function to call to return ruler string.
  This variable is expected to be made buffer-local by modes.")
  
  (defconst ruler-mode-header-line-format
!   '(:eval (funcall (if ruler-mode-ruler-function
! 		       ruler-mode-ruler-function
! 		     'ruler-mode-ruler)))
    "`header-line-format' used in ruler mode.
! If the non-nil value for ruler-mode-ruler-function is given, use it.
! Else use `ruler-mode-ruler' is used as default value.")
  
  ;;;###autoload
  (define-minor-mode ruler-mode
--- 531,545 ----
  
  (defvar ruler-mode-header-line-format-old nil
    "Hold previous value of `header-line-format'.")
  
! (defvar ruler-mode-ruler-function 'ruler-mode-ruler
!   "Function to call to return ruler header line format.
  This variable is expected to be made buffer-local by modes.")
  
  (defconst ruler-mode-header-line-format
!   '(:eval (funcall ruler-mode-ruler-function))
    "`header-line-format' used in ruler mode.
! Call `ruler-mode-ruler-function' to compute the ruler value.")
  
  ;;;###autoload
  (define-minor-mode ruler-mode
***************
*** 556,573 ****
          ;; When `ruler-mode' is on save previous header line format
          ;; and install the ruler header line format.
          (when (local-variable-p 'header-line-format)
!           (setq ruler-mode-header-line-format-old header-line-format))
          (setq header-line-format ruler-mode-header-line-format)
!         (add-hook 'post-command-hook    ; add local hook
!                   #'force-mode-line-update nil t))
      ;; When `ruler-mode' is off restore previous header line format if
      ;; the current one is the ruler header line format.
      (when (eq header-line-format ruler-mode-header-line-format)
        (kill-local-variable 'header-line-format)
        (when (local-variable-p 'ruler-mode-header-line-format-old)
!         (setq header-line-format ruler-mode-header-line-format-old)))
!     (remove-hook 'post-command-hook     ; remove local hook
!                  #'force-mode-line-update t)))
  \f
  ;; Add ruler-mode to the minor mode menu in the mode line
  (define-key mode-line-mode-menu [ruler-mode]
--- 552,569 ----
          ;; When `ruler-mode' is on save previous header line format
          ;; and install the ruler header line format.
          (when (local-variable-p 'header-line-format)
!           (set (make-local-variable 'ruler-mode-header-line-format-old)
!                header-line-format))
          (setq header-line-format ruler-mode-header-line-format)
!         (add-hook 'post-command-hook 'force-mode-line-update nil t))
      ;; When `ruler-mode' is off restore previous header line format if
      ;; the current one is the ruler header line format.
      (when (eq header-line-format ruler-mode-header-line-format)
        (kill-local-variable 'header-line-format)
        (when (local-variable-p 'ruler-mode-header-line-format-old)
!         (setq header-line-format ruler-mode-header-line-format-old)
!         (kill-local-variable 'ruler-mode-header-line-format-old)))
!     (remove-hook 'post-command-hook 'force-mode-line-update t)))
  \f
  ;; Add ruler-mode to the minor mode menu in the mode line
  (define-key mode-line-mode-menu [ruler-mode]
***************
*** 621,753 ****
  (defsubst ruler-mode-space (width &rest props)
    "Return a single space string of WIDTH times the normal character width.
  Optional argument PROPS specifies other text properties to apply."
!   (if (> width 0)
!       (apply 'propertize " " 'display (list 'space :width width) props)
!     ""))
  \f
  (defun ruler-mode-ruler ()
!   "Return a string ruler."
!   (when ruler-mode
!     (let* ((w     (window-width))
!            (m     (window-margins))
!            (lsb   (scroll-bar-columns 'left))
!            (lf    (fringe-columns 'left t))
!            (lm    (or (car m) 0))
!            (rsb   (scroll-bar-columns 'right))
!            (rf    (fringe-columns 'right t))
!            (rm    (or (cdr m) 0))
!            (ruler (make-string w ruler-mode-basic-graduation-char))
!            (i     0)
!            (j     (window-hscroll))
!            k c l1 l2 r2 r1 h1 h2 f1 f2)
! 
!       ;; Setup the default properties.
!       (put-text-property 0 w 'face 'ruler-mode-default-face ruler)
!       (put-text-property 0 w
!                          'help-echo
!                          (cond
!                           (ruler-mode-show-tab-stops
!                            ruler-mode-ruler-help-echo-when-tab-stops)
!                           (goal-column
!                            ruler-mode-ruler-help-echo-when-goal-column)
!                           (t
!                            ruler-mode-ruler-help-echo))
!                          ruler)
!       ;; Setup the local map.
!       (put-text-property 0 w 'local-map ruler-mode-map ruler)
! 
!       ;; Setup the active area.
!       (while (< i w)
!         ;; Graduations.
!         (cond
!          ;; Show a number graduation.
!          ((= (mod j 10) 0)
!           (setq c (number-to-string (/ j 10))
!                 m (length c)
!                 k i)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-column-number-face
!            ruler)
!           (while (and (> m 0) (>= k 0))
!             (aset ruler k (aref c (setq m (1- m))))
!             (setq k (1- k))))
!          ;; Show an intermediate graduation.
!          ((= (mod j 5) 0)
!           (aset ruler i ruler-mode-inter-graduation-char)))
!         ;; Special columns.
!         (cond
!          ;; Show the `current-column' marker.
!          ((= j (current-column))
!           (aset ruler i ruler-mode-current-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-current-column-face
!            ruler))
!          ;; Show the `goal-column' marker.
!          ((and goal-column (= j goal-column))
!           (aset ruler i ruler-mode-goal-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-goal-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-goal-column-help-echo
!            ruler))
!          ;; Show the `comment-column' marker.
!          ((= j comment-column)
!           (aset ruler i ruler-mode-comment-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-comment-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-comment-column-help-echo
!            ruler))
!          ;; Show the `fill-column' marker.
!          ((= j fill-column)
!           (aset ruler i ruler-mode-fill-column-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-fill-column-face
!            ruler)
!           (put-text-property
!            i (1+ i) 'help-echo ruler-mode-fill-column-help-echo
!            ruler))
!          ;; Show the `tab-stop-list' markers.
!          ((and ruler-mode-show-tab-stops (member j tab-stop-list))
!           (aset ruler i ruler-mode-tab-stop-char)
!           (put-text-property
!            i (1+ i) 'face 'ruler-mode-tab-stop-face
!            ruler)))
!         (setq i (1+ i)
!               j (1+ j)))
! 
!       ;; Highlight the fringes and margins.
!       (if (nth 2 (window-fringes))
!           ;; fringes outside margins.
!           (setq l1 lf
!                 l2 lm
!                 r2 rm
!                 r1 rf
!                 h1 ruler-mode-fringe-help-echo
!                 h2 ruler-mode-margin-help-echo
!                 f1 'ruler-mode-fringes-face
!                 f2 'ruler-mode-margins-face)
!         ;; fringes inside margins.
!         (setq l1 lm
!               l2 lf
!               r2 rf
!               r1 rm
!               h1 ruler-mode-margin-help-echo
!               h2 ruler-mode-fringe-help-echo
!               f1 'ruler-mode-margins-face
!               f2 'ruler-mode-fringes-face))
!       ;; Return the ruler propertized string.  Using list here,
!       ;; instead of concat visually separate the different areas.
!       (list
!        (ruler-mode-space lsb 'face 'ruler-mode-pad-face)
!        (ruler-mode-space l1 'face f1 'help-echo (format h1 "Left" l1))
!        (ruler-mode-space l2 'face f2 'help-echo (format h2 "Left" l2))
!        ruler
!        (ruler-mode-space r2 'face f2 'help-echo (format h2 "Right" r2))
!        (ruler-mode-space r1 'face f1 'help-echo (format h1 "Right" r1))
!        (ruler-mode-space rsb 'face 'ruler-mode-pad-face)))))
  
  (provide 'ruler-mode)
  
--- 617,740 ----
  (defsubst ruler-mode-space (width &rest props)
    "Return a single space string of WIDTH times the normal character width.
  Optional argument PROPS specifies other text properties to apply."
!   (apply 'propertize " " 'display (list 'space :width width) props))
  \f
  (defun ruler-mode-ruler ()
!   "Compute and return an header line ruler."
!   (let* ((w (window-width))
!          (m (window-margins))
!          (f (window-fringes))
!          (i 0)
!          (j (window-hscroll))
!          ;; Setup the scrollbar, fringes, and margins areas.
!          (lf (ruler-mode-space
!               'left-fringe
!               'face 'ruler-mode-fringes-face
!               'help-echo (format ruler-mode-fringe-help-echo
!                                  "Left" (or (car f) 0))))
!          (rf (ruler-mode-space
!               'right-fringe
!               'face 'ruler-mode-fringes-face
!               'help-echo (format ruler-mode-fringe-help-echo
!                                  "Right" (or (cadr f) 0))))
!          (lm (ruler-mode-space
!               'left-margin
!               'face 'ruler-mode-margins-face
!               'help-echo (format ruler-mode-margin-help-echo
!                                  "Left" (or (car m) 0))))
!          (rm (ruler-mode-space
!               'right-margin
!               'face 'ruler-mode-margins-face
!               'help-echo (format ruler-mode-margin-help-echo
!                                  "Right" (or (cdr m) 0))))
!          (sb (ruler-mode-space
!               'scroll-bar
!               'face 'ruler-mode-pad-face))
!          ;; Remember the scrollbar vertical type.
!          (sbvt (car (window-current-scroll-bars)))
!          ;; Create an "clean" ruler.
!          (ruler
!           (propertize
!            (make-string w ruler-mode-basic-graduation-char)
!            'face 'ruler-mode-default-face
!            'local-map ruler-mode-map
!            'help-echo (cond
!                        (ruler-mode-show-tab-stops
!                         ruler-mode-ruler-help-echo-when-tab-stops)
!                        (goal-column
!                         ruler-mode-ruler-help-echo-when-goal-column)
!                        (ruler-mode-ruler-help-echo))))
!          k c)
!     ;; Setup the active area.
!     (while (< i w)
!       ;; Graduations.
!       (cond
!        ;; Show a number graduation.
!        ((= (mod j 10) 0)
!         (setq c (number-to-string (/ j 10))
!               m (length c)
!               k i)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-column-number-face
!          ruler)
!         (while (and (> m 0) (>= k 0))
!           (aset ruler k (aref c (setq m (1- m))))
!           (setq k (1- k))))
!        ;; Show an intermediate graduation.
!        ((= (mod j 5) 0)
!         (aset ruler i ruler-mode-inter-graduation-char)))
!       ;; Special columns.
!       (cond
!        ;; Show the `current-column' marker.
!        ((= j (current-column))
!         (aset ruler i ruler-mode-current-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-current-column-face
!          ruler))
!        ;; Show the `goal-column' marker.
!        ((and goal-column (= j goal-column))
!         (aset ruler i ruler-mode-goal-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-goal-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-goal-column-help-echo
!          ruler))
!        ;; Show the `comment-column' marker.
!        ((= j comment-column)
!         (aset ruler i ruler-mode-comment-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-comment-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-comment-column-help-echo
!          ruler))
!        ;; Show the `fill-column' marker.
!        ((= j fill-column)
!         (aset ruler i ruler-mode-fill-column-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-fill-column-face
!          ruler)
!         (put-text-property
!          i (1+ i) 'help-echo ruler-mode-fill-column-help-echo
!          ruler))
!        ;; Show the `tab-stop-list' markers.
!        ((and ruler-mode-show-tab-stops (member j tab-stop-list))
!         (aset ruler i ruler-mode-tab-stop-char)
!         (put-text-property
!          i (1+ i) 'face 'ruler-mode-tab-stop-face
!          ruler)))
!       (setq i (1+ i)
!             j (1+ j)))
!     ;; Return the ruler propertized string.  Using list here,
!     ;; instead of concat visually separate the different areas.
!     (if (nth 2 (window-fringes))
!         ;; fringes outside margins.
!         (list "" (and (eq 'left sbvt) sb) lf lm
!               ruler rm rf (and (eq 'right sbvt) sb))
!       ;; fringes inside margins.
!       (list "" (and (eq 'left sbvt) sb) lm lf
!             ruler rf rm (and (eq 'right sbvt) sb)))))
  
  (provide 'ruler-mode)
  

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: use of symbolic display elements in ruler-mode
@ 2004-03-19 13:45 David PONCE
  0 siblings, 0 replies; 7+ messages in thread
From: David PONCE @ 2004-03-19 13:45 UTC (permalink / raw)
  Cc: emacs-devel

Kim,

>>Following is a new patch that take into account those changes.
>>
>>P.S.: Please, could someone, who has CVS write access, install
>>         the patch for me?  Thanks!
> 
> 
> Done.

Thank you very much!

> 
> PS:  Byte compiler barfs about fringe-columns and scroll-bar-columns.
> 

Not for me.  After updating, recompile just said:

? make recompile
../src/emacs -batch --no-site-file --multibyte
             -f batch-byte-recompile-directory /home/ponce/installs/emacs/lisp
Checking /home/ponce/installs/emacs/lisp...
Compiling /home/ponce/installs/emacs/lisp/ruler-mode.el...

In end of data:
ruler-mode.el:746:1:Warning: the function `widget-value' might not be defined
    at runtime.
Wrote /home/ponce/installs/emacs/lisp/ruler-mode.elc
[...]

David

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: use of symbolic display elements in ruler-mode
  2004-03-19  9:51 David PONCE
@ 2004-03-19 14:20 ` Kim F. Storm
  0 siblings, 0 replies; 7+ messages in thread
From: Kim F. Storm @ 2004-03-19 14:20 UTC (permalink / raw)
  Cc: emacs-devel

David PONCE <david.ponce@wanadoo.fr> writes:

> Following is a new patch that take into account those changes.
> 
> P.S.: Please, could someone, who has CVS write access, install
>          the patch for me?  Thanks!

Done.

PS:  Byte compiler barfs about fringe-columns and scroll-bar-columns.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-03-19 14:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-18 13:14 use of symbolic display elements in ruler-mode David PONCE
2004-03-18 14:27 ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2004-03-18 14:52 David PONCE
2004-03-19  1:50 ` Kim F. Storm
2004-03-19  9:51 David PONCE
2004-03-19 14:20 ` Kim F. Storm
2004-03-19 13:45 David PONCE

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.