yatex

diff yatexsec.el @ 623:6a0fea36298f

Code cleaning for Emacs31
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 01 Aug 2026 13:51:09 +0900
parents 5eb2b1d824f3
children
line diff
     1.1 --- a/yatexsec.el	Wed May 30 13:54:46 2018 +0900
     1.2 +++ b/yatexsec.el	Sat Aug 01 13:51:09 2026 +0900
     1.3 @@ -1,7 +1,7 @@
     1.4 -;;; yatexsec.el --- YaTeX sectioning browser
     1.5 +;;; yatexsec.el --- YaTeX sectioning browser -*- lexical-binding: nil -*-
     1.6  ;;; 
     1.7 -;;; (c) 1994-2017 by HIROSE Yuuji [yuuji@yatex.org]
     1.8 -;;; Last modified Wed May 30 13:29:50 2018 on firestorm
     1.9 +;;; (c) 1994-2017,2026 by HIROSE Yuuji [yuuji@yatex.org]
    1.10 +;;; Last modified Sat Aug  1 13:35:14 2026 on firestorm
    1.11  ;;; $Id$
    1.12  
    1.13  ;;; Code:
    1.14 @@ -26,8 +26,7 @@
    1.15    (let ((ch ?0))
    1.16      (while (<= ch ?9)
    1.17        (define-key map (char-to-string ch) 'YaTeX-sectioning-hide)
    1.18 -      (setq ch (1+ ch))))
    1.19 -)
    1.20 +      (setq ch (1+ ch)))))
    1.21  
    1.22  (defvar YaTeX-sectioning-minibuffer-map nil
    1.23    "Key map used in minibuffer for sectioning.")
    1.24 @@ -62,8 +61,7 @@
    1.25      'YaTeX-sectioning-recenter)
    1.26    (define-key YaTeX-sectioning-minibuffer-map "?"
    1.27      'YaTeX-sectioning-help)
    1.28 -  (YaTeX-sectioning-map-hide YaTeX-sectioning-minibuffer-map)
    1.29 -)
    1.30 +  (YaTeX-sectioning-map-hide YaTeX-sectioning-minibuffer-map))
    1.31  
    1.32  (defvar YaTeX-sectioning-buffer-map nil
    1.33    "Key map used in YaTeX-sectioning-buffer.")
    1.34 @@ -91,8 +89,7 @@
    1.35    (and YaTeX-emacs-19 (boundp 'window-system) (eq window-system 'x)
    1.36         (define-key YaTeX-sectioning-buffer-map [?\C-/]
    1.37  	 'YaTeX-shift-section-undo))
    1.38 -  (YaTeX-sectioning-map-hide YaTeX-sectioning-buffer-map)
    1.39 -)
    1.40 +  (YaTeX-sectioning-map-hide YaTeX-sectioning-buffer-map))
    1.41  
    1.42  (defun YaTeX-sectioning-mode ()
    1.43    "Mode for browsing document's sectioning structure.
    1.44 @@ -110,8 +107,7 @@
    1.45    (interactive)
    1.46    (setq major-mode 'YaTeX-sectioning-mode
    1.47  	mode-name "sectioning")
    1.48 -  (use-local-map YaTeX-sectioning-buffer-map)
    1.49 -)
    1.50 +  (use-local-map YaTeX-sectioning-buffer-map))
    1.51  
    1.52  (defvar YaTeX-sectioning-buffer-parent nil)
    1.53  (defun YaTeX-sectioning-buffer-jump-internal (&optional keep)
    1.54 @@ -152,14 +148,12 @@
    1.55    (if (and YaTeX-sectioning-buffer-parent
    1.56  	   (get-buffer YaTeX-sectioning-buffer-parent))
    1.57        (YaTeX-sectioning-buffer-jump-internal keep)
    1.58 -    (message "No line number expression."))
    1.59 -)
    1.60 +    (message "No line number expression.")))
    1.61  
    1.62  (defun YaTeX-sectioning-buffer-show ()
    1.63    "Show corresponding sectioning unit with current line."
    1.64    (interactive)
    1.65 -  (YaTeX-sectioning-buffer-jump-internal t)
    1.66 -)
    1.67 +  (YaTeX-sectioning-buffer-jump-internal t))
    1.68  
    1.69  (defun YaTeX-sectioning-hide-under (n)
    1.70    "Hide sectioning commands under level N."
    1.71 @@ -176,8 +170,8 @@
    1.72      (if (numberp selective-display)
    1.73  	(setq mode-name (format "level %d" (1- selective-display)))
    1.74        (setq mode-name (format "all")))
    1.75 -    (select-window cw))
    1.76 -)
    1.77 +    (select-window cw)))
    1.78 +
    1.79  (defun YaTeX-sectioning-hide ()
    1.80    "Call YaTeX-sectioning-hide-under with argument according to pressed key."
    1.81    (interactive)
    1.82 @@ -212,8 +206,7 @@
    1.83  	  (momentary-string-display "" (point-min)))
    1.84        (bury-buffer hb)
    1.85        (switch-to-buffer sb)
    1.86 -      (select-window cw)))
    1.87 -)
    1.88 +      (select-window cw))))
    1.89  
    1.90  (defun YaTeX-sectioning-up (n)
    1.91    "Up section level.
    1.92 @@ -233,14 +226,12 @@
    1.93  	(if (or (< level 0) (>= level (length alist)))
    1.94  	    (ding)
    1.95  	  (YaTeX-minibuffer-erase)
    1.96 -	  (insert (concat (car (nth level alist)) (if aster "*" ""))))))
    1.97 -)
    1.98 +	  (insert (concat (car (nth level alist)) (if aster "*" "")))))))
    1.99  
   1.100  (defun YaTeX-sectioning-down (n)
   1.101    "Down section level."
   1.102    (interactive "p")
   1.103 -  (YaTeX-sectioning-up (- n))
   1.104 -)
   1.105 +  (YaTeX-sectioning-up (- n)))
   1.106  
   1.107  (defun YaTeX-sectioning-scroll-up (n)
   1.108    (interactive "P")
   1.109 @@ -249,8 +240,7 @@
   1.110      (YaTeX-showup-buffer section-buffer nil t)
   1.111      (unwind-protect
   1.112  	(scroll-up (or n (- (window-height) 2)))
   1.113 -      (select-window cw)))
   1.114 -)
   1.115 +      (select-window cw))))
   1.116  
   1.117  (defun YaTeX-sectioning-scroll-down (n)
   1.118    (interactive "P")
   1.119 @@ -259,8 +249,7 @@
   1.120      (YaTeX-showup-buffer section-buffer nil t)
   1.121      (unwind-protect
   1.122  	(scroll-down (or n (- (window-height) 2)))
   1.123 -      (select-window cw)))
   1.124 -)
   1.125 +      (select-window cw))))
   1.126  
   1.127  (defun YaTeX-sectioning-recenter (arg)
   1.128    "Recenter `<<--' line"
   1.129 @@ -272,8 +261,7 @@
   1.130  	  (or (search-forward "<<--" nil t)
   1.131  	      (search-backward "<<--" nil))
   1.132  	  (recenter (or arg (/ (window-height) 2))))
   1.133 -      (select-window cw)))
   1.134 -)
   1.135 +      (select-window cw))))
   1.136  
   1.137  (defvar YaTeX-sectioning-minibuffer " *sectioning*"
   1.138    "Miniuffer used for sectioning")
   1.139 @@ -282,16 +270,14 @@
   1.140    (interactive)
   1.141    (let ((minibuffer-completion-table table))
   1.142      (read-from-minibuffer
   1.143 -     prompt default YaTeX-sectioning-minibuffer-map))
   1.144 -)
   1.145 +     prompt default YaTeX-sectioning-minibuffer-map)))
   1.146  
   1.147  (defun YaTeX-get-sectioning-level ()
   1.148    "Get section-level on the cursor."
   1.149     (cdr-safe (assoc (buffer-substring
   1.150  		     (point)
   1.151  		     (progn (skip-chars-forward "a-z") (point)))
   1.152 -		     YaTeX-sectioning-level))
   1.153 -)
   1.154 +		     YaTeX-sectioning-level)))
   1.155  
   1.156  (defvar YaTeX-sectioning-buffer "*Sectioning lines*")
   1.157  (defvar YaTeX-sectioning-indent 1)
   1.158 @@ -330,8 +316,7 @@
   1.159        (setq YaTeX-sectioning-buffer-parent cb)
   1.160        (if (numberp selective-display)
   1.161  	  (setq mode-name (format "level %d" (1- selective-display))))
   1.162 -      YaTeX-sectioning-buffer))
   1.163 -)
   1.164 +      YaTeX-sectioning-buffer)))
   1.165  
   1.166  (defvar YaTeX-pending-undo nil)
   1.167  (defun YaTeX-section-overview ()
   1.168 @@ -360,8 +345,7 @@
   1.169        (forward-line 1)
   1.170        (if (eobp) (recenter -1) (recenter -3))
   1.171        (select-window cw)
   1.172 -      command))
   1.173 -)
   1.174 +      command)))
   1.175  
   1.176  ;;;###autoload
   1.177  (defun YaTeX-make-section-with-overview ()
   1.178 @@ -373,21 +357,19 @@
   1.179      "Sectioning(Up=C-p, Down=C-n, Help=?): "
   1.180      YaTeX-sectioning-level (YaTeX-section-overview))
   1.181     "{}")
   1.182 -  (forward-char -1)
   1.183 -)
   1.184 +  (forward-char -1))
   1.185  
   1.186  (defun YaTeX-shifted-section (sc n)
   1.187    "Get SC's N-shifted sectioning command."
   1.188    (let (lv)
   1.189      (setq lv (- (cdr (assoc sc YaTeX-sectioning-level)) n)
   1.190  	  lv (max (min YaTeX-sectioning-max-level lv) 0))
   1.191 -    (car (nth lv YaTeX-sectioning-level)))
   1.192 -)
   1.193 +    (car (nth lv YaTeX-sectioning-level))))
   1.194  
   1.195  (defun YaTeX-shift-section-up (n)
   1.196    "Shift sectioning command down by level N."
   1.197    (interactive "p")
   1.198 -  (let ((cb (current-buffer)) sc nsc lv)
   1.199 +  (let ((cb (current-buffer)) nsc lv)
   1.200      (if (and YaTeX-sectioning-buffer-parent
   1.201  	     (get-buffer YaTeX-sectioning-buffer-parent)
   1.202  	     (save-excursion
   1.203 @@ -421,13 +403,13 @@
   1.204  	    (undo-boundary))
   1.205  	  (set-buffer-modified-p nil)
   1.206  	  (setq YaTeX-pending-undo pending-undo-list)
   1.207 -	  )))
   1.208 -)
   1.209 +	  ))))
   1.210 +
   1.211  (defun YaTeX-shift-section-down (n)
   1.212    "Shift sectioning command down by level N."
   1.213    (interactive "p")
   1.214 -  (YaTeX-shift-section-up (- n))
   1.215 -)
   1.216 +  (YaTeX-shift-section-up (- n)))
   1.217 +
   1.218  (defun YaTeX-shift-section-undo (arg)
   1.219    "Undo YaTeX-shift-section-up/down."
   1.220    (interactive "p")
   1.221 @@ -449,8 +431,8 @@
   1.222  	   (undo arg)
   1.223  	   (setq YaTeX-pending-undo pending-undo-list))
   1.224  	 (goto-buffer-window cb)
   1.225 -	 (setq this-command 'YaTeX-shift-section-undo)))
   1.226 -)
   1.227 +	 (setq this-command 'YaTeX-shift-section-undo))))
   1.228 +
   1.229  (defun YaTeX-sync-section-buffer ()
   1.230    "Synchronize *Sectioning Lines* buffer with parent buffer."
   1.231    (interactive)
   1.232 @@ -460,8 +442,8 @@
   1.233  	(set-buffer (get-buffer YaTeX-sectioning-buffer-parent))
   1.234  	(YaTeX-section-overview)
   1.235  	(switch-to-buffer cb)
   1.236 -	(goto-char p)))
   1.237 -)
   1.238 +	(goto-char p))))
   1.239 +
   1.240  (defun YaTeX-shift-section-up-region (beg end n)
   1.241    "Shift sectioning commands in region down by level N."
   1.242    (interactive "r\np")
   1.243 @@ -503,22 +485,22 @@
   1.244  		(insert (cdr (car repllist)))
   1.245  		(goto-char (match-beginning 0))))
   1.246  	  (setq repllist (cdr repllist))))
   1.247 -      (goto-buffer-window cb)))
   1.248 -)
   1.249 +      (goto-buffer-window cb))))
   1.250 +
   1.251  (defun YaTeX-shift-section-down-region (beg end n)
   1.252    "Shift sectioning commands in region down by level N."
   1.253    (interactive "r\np")
   1.254 -  (YaTeX-shift-section-up-region beg end (- n))
   1.255 -)
   1.256 +  (YaTeX-shift-section-up-region beg end (- n)))
   1.257 +
   1.258  (defun YaTeX-sectioning-buffer-next-line (n)
   1.259    "Move to next line in *Sectioning Lines* buffer."
   1.260    (interactive "p")
   1.261    (forward-line n)
   1.262 -  (skip-chars-forward " \t%")
   1.263 -)
   1.264 +  (skip-chars-forward " \t%"))
   1.265 +
   1.266  (defun YaTeX-sectioning-buffer-prev-line (n)
   1.267    "Move to previous line in *Sectioning Lines* buffer."
   1.268    (interactive "p")
   1.269 -  (YaTeX-sectioning-buffer-next-line (- n))
   1.270 -)
   1.271 +  (YaTeX-sectioning-buffer-next-line (- n)))
   1.272 +
   1.273  (provide 'yatexsec)