+;; 10 chars for the "address: "
+;; 32 chars for the hexlified bytes
+;; 1 char for the space
+;; 16 chars for the character display
+;; X chars for the spaces (128 bits divided by the hexl-bits)
+;; 1 char for the newline.
+(defun hexl-line-displen ()
+ "The length of a hexl display line (varies with `hexl-bits')."
+ (+ 60 (/ 128 (or hexl-bits 16))))
+
+(defun hexl-mode--minor-mode-p (var)
+ (memq var '(ruler-mode hl-line-mode)))
+
+(defun hexl-mode--setq-local (var val)
+ ;; `var' can be either a symbol or a pair, in which case the `car'
+ ;; is the getter function and the `cdr' is the corresponding setter.
+ (unless (or (member var hexl-mode--old-var-vals)
+ (assoc var hexl-mode--old-var-vals))
+ (push (if (or (consp var) (boundp var))
+ (cons var
+ (if (consp var) (funcall (car var)) (symbol-value var)))
+ var)
+ hexl-mode--old-var-vals))
+ (cond
+ ((consp var) (funcall (cdr var) val))
+ ((hexl-mode--minor-mode-p var) (funcall var (if val 1 -1)))
+ (t (set (make-local-variable var) val))))
+