emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master cdf5340: New commands image-scroll-left and image-s


From: Mark Oteiza
Subject: [Emacs-diffs] master cdf5340: New commands image-scroll-left and image-scroll-right
Date: Fri, 16 Dec 2016 03:00:26 +0000 (UTC)

branch: master
commit cdf5340f51d4346c276102331e3ed29561753b26
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>

    New commands image-scroll-left and image-scroll-right
    
    * etc/NEWS: Mention them.
    * lisp/image-mode.el (image-scroll-left, image-scroll-right): New
    functions.
---
 etc/NEWS           |    6 ++++++
 lisp/image-mode.el |   44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index fdd901f..e69ba87 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -457,6 +457,12 @@ details.
 provided: 'image-property'.
 
 ---
+*** New commands 'image-scroll-left' and 'image-scroll-right'
+for 'image-mode' that complement 'image-scroll-up' and
+'image-scroll-down': they have the same prefix arg behavior and stop
+at image boundaries.
+
+---
 ** The default 'Info-default-directory-list' no longer checks some obsolete
 directory suffixes (gnu, gnu/lib, gnu/lib/emacs, emacs, lib, lib/emacs)
 when searching for info directories.
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index ce56208..4a7178d 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -273,6 +273,48 @@ When calling from a program, supply as argument a number, 
nil, or `-'."
            (max 0 (- win-height next-screen-context-lines)))))
        (t (image-next-line (- (prefix-numeric-value n))))))
 
+(defun image-scroll-left (&optional n)
+  "Scroll image in current window leftward by N character widths.
+Stop if the right edge of the image is reached.
+If ARG is omitted or nil, scroll leftward by a near full screen.
+A near full screen is 2 columns less than a full screen.
+Negative ARG means scroll rightward.
+If ARG is the atom `-', scroll rightward by nearly full screen.
+When calling from a program, supply as argument a number, nil, or `-'."
+  (interactive "P")
+  (cond ((null n)
+        (let* ((edges (window-inside-edges))
+               (win-width (- (nth 2 edges) (nth 0 edges))))
+          (image-forward-hscroll
+           (max 0 (- win-width 2)))))
+       ((eq n '-)
+        (let* ((edges (window-inside-edges))
+               (win-width (- (nth 2 edges) (nth 0 edges))))
+          (image-forward-hscroll
+           (min 0 (- 2 win-width)))))
+       (t (image-forward-hscroll (prefix-numeric-value n)))))
+
+(defun image-scroll-right (&optional n)
+  "Scroll image in current window rightward by N character widths.
+Stop if the left edge of the image is reached.
+If ARG is omitted or nil, scroll downward by a near full screen.
+A near full screen is 2 less than a full screen.
+Negative ARG means scroll leftward.
+If ARG is the atom `-', scroll leftward by nearly full screen.
+When calling from a program, supply as argument a number, nil, or `-'."
+  (interactive "P")
+  (cond ((null n)
+        (let* ((edges (window-inside-edges))
+               (win-width (- (nth 2 edges) (nth 0 edges))))
+          (image-forward-hscroll
+           (min 0 (- 2 win-width)))))
+       ((eq n '-)
+        (let* ((edges (window-inside-edges))
+               (win-width (- (nth 2 edges) (nth 0 edges))))
+          (image-forward-hscroll
+           (max 0 (- win-width 2)))))
+       (t (image-forward-hscroll (- (prefix-numeric-value n))))))
+
 (defun image-bol (arg)
   "Scroll horizontally to the left edge of the image in the current window.
 With argument ARG not nil or 1, move forward ARG - 1 lines first,
@@ -401,6 +443,8 @@ call."
     (define-key map [remap scroll-down] 'image-scroll-down)
     (define-key map [remap scroll-up-command] 'image-scroll-up)
     (define-key map [remap scroll-down-command] 'image-scroll-down)
+    (define-key map [remap scroll-left] 'image-scroll-left)
+    (define-key map [remap scroll-right] 'image-scroll-right)
     (define-key map [remap move-beginning-of-line] 'image-bol)
     (define-key map [remap move-end-of-line] 'image-eol)
     (define-key map [remap beginning-of-buffer] 'image-bob)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]