emacs-devel
[Top][All Lists]
Advanced

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

suggested new command `picture-mouse-set-point'


From: John Paul Wallington
Subject: suggested new command `picture-mouse-set-point'
Date: Wed, 23 Oct 2002 19:04:41 +0100

Here is a patch providing a mouse command to set point to the position
clicked on in `picture-mode' making whitespace if necessary, as
suggested by Kai and others.  It seems okay, but isn't great.

Is it worth installing as is?  Can anyone suggest improvements?


--- /build-emacs/emacs/lisp/textmodes/picture.el.~1.40.~        Mon Jul  1 
08:47:22 2002
+++ /build-emacs/emacs/lisp/textmodes/picture.el        Wed Oct 23 18:56:22 2002
@@ -1,6 +1,6 @@
 ;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model
 
-;; Copyright (C) 1985, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1994, 2002 Free Software Foundation, Inc.
 
 ;; Author: K. Shane Hartman
 ;; Maintainer: FSF
@@ -226,6 +226,18 @@
   (interactive "p")
   (picture-motion (- arg)))
 
+(defun picture-mouse-set-point (event)
+  "Move point to the position clicked on, making whitespace if necessary."
+  (interactive "e")
+  (let* ((pos (posn-col-row (event-start event)))
+        (x (car pos))
+        (y (cdr pos))
+        (current-row (count-lines (window-start) (line-beginning-position))))
+    (unless (equal x (current-column))
+      (picture-forward-column (- x (current-column))))
+    (unless (equal y current-row)
+      (picture-move-down (- y current-row)))))
+
 
 ;; Picture insertion and deletion.
 
@@ -602,6 +614,7 @@
       (picture-substitute 'previous-line 'picture-move-up)
       (picture-substitute 'beginning-of-line 'picture-beginning-of-line)
       (picture-substitute 'end-of-line 'picture-end-of-line)
+      (picture-substitute 'mouse-set-point 'picture-mouse-set-point)
 
       (define-key picture-mode-map "\C-c\C-d" 'delete-char)
       (define-key picture-mode-map "\e\t" 'picture-toggle-tab-state)

-- 
John Paul Wallington





reply via email to

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