From xemacs-m  Tue May 27 01:34:36 1997
Received: from web2.ndsoft.com (root@web2.ndsoft.com [199.203.68.30])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id BAA19745
	for <xemacs-beta@xemacs.org>; Tue, 27 May 1997 01:34:25 -0500 (CDT)
Received: from romeo.ndsoft.com (romeo [194.90.171.61])
	by web2.ndsoft.com (8.8.5/8.8.5) with SMTP id IAA06249
	for <xemacs-beta@xemacs.org>; Tue, 27 May 1997 08:24:11 +0300
Received: from ndsoft.com (piccard) by romeo.ndsoft.com (4.1/SMI-4.1)
	id AA09676; Tue, 27 May 97 09:34:48 IDT
Received: by ndsoft.com (4.1/SMI-4.1)
	id AA01252; Tue, 27 May 97 09:34:45 IDT
Date: Tue, 27 May 97 09:34:45 IDT
Message-Id: <9705270634.AA01252@ndsoft.com>
From: "Amir J. Katz" <amir@piccard.ndsoft.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: xemacs-beta@xemacs.org (XEmacs Beta List)
Subject: Odds and ends to be included in next beta
X-Mailer: VM 6.30 under 20.2 XEmacs Lucid (beta1)
Reply-To: amir@ndsoft.com
X-Face:  ##A>t)R3?k=s5sw'(<v}xy5K8i]2+gl@^A7,ZN.8v5,).3hzG^rRmob&I-^&2m>5K\s3KSk+iIbgHIrS_8k}#}MVff9#>t4r!a>yp<qFqhM>pweVJ!^S<@teMIaDDU(gXk!,)m]o|"X


Following Steve's mail, here are some very useful functions, which,
AFAIK, have not been implemented (or this implementation is better).
I would love to see these included somewhere in the distribution.
If any of these is already implemented, please let me know.

Authors of the last three functions are unknown.

1. x-delete-line: 
   Delete arg lines (1 if arg is nil) from the current line,
   regardless the cursor position in the line or blank line(s) and copy
   it to the clipboard.

2. insert-line:
   Insert a line before the current line, no matter where the cursor is.

3. insert-line-after:
   Insert a line after the current line, no matter where the cursor is.

4. NDS::what-cursor-position-and-line:
   Print info on cursor position (on screen and within buffer):
   The character code in octal, decimal and hex, the position of point, the
   line and the column in relation to their respective totals.

Enjoy.

------------------------------------------

;; From: miko@lion.dgt.co.il (Avi Nahum)
;; Date: Sep. 28, 1995

(defun x-delete-line (&optional arg)
  "Delete arg lines (1 if arg is nil) from the current line,
regardless the cursor position in the line or blank line(s) and copy
it to the clipboard."
  (interactive "*P")
  (let* ((from-pos (progn
		     (beginning-of-line)
		     (point)))
	 (to-pos (progn
		   (forward-line (if arg (prefix-numeric-value arg) 1))
		   (point))))
    (if (= from-pos to-pos)
	(signal 'end-of-buffer nil)
      (progn
	(kill-region from-pos to-pos)
	(x-own-clipboard (car kill-ring))
	(x-disown-selection nil)))))

------------------------------------------

(defun insert-line ()
  "Insert a line before the current line, no matter where the cursor is."
  (interactive)
  (let ((org-point (point)))
    (condition-case conditions
	(progn
	  (beginning-of-line)
	  (open-line 1)
	  )
      (error (goto-char org-point)
	     (signal (car conditions) (cdr conditions))))))

------------------------------------------

(defun insert-line-after ()
  "Insert a line after the current line, no matter where the cursor is."
  (interactive)

  (let ((org-point (point)))
    (condition-case conditions
	(progn
	  (end-of-line)
	  (open-line 1)
	  (next-line 1)
	  (end-of-line)
	  )
      (error (goto-char org-point)
	     (signal (car conditions) (cdr conditions))))))

------------------------------------------

(defun NDS::what-cursor-position-and-line ()
  "Print info on cursor position (on screen and within buffer):
The character code in octal, decimal and hex, the position of point, the
line and the column in relation to their respective totals."
  (interactive)
  (let* ((char (following-char))
	 (beg (point-min))
	 (end (point-max))
         (pos (point))
	 (total (buffer-size))
	 (percent (if (> total 50000)
		      ;; Avoid overflow from multiplying by 100!
		      (/ (+ (/ total 200) (1- pos)) (max (/ total 100) 1))
		    (/ (+ (/ total 2) (* 100 (1- pos))) (max total 1))))
	 (hscroll (if (= (window-hscroll) 0)
		      ""
		    (format " Hscroll=%d" (window-hscroll))))
	 (col (current-column))
	 (total-col (save-excursion
		      (end-of-line)
		      (current-column)))
	 ;; if final newline is missing, count that line anyway
	 (total-lines (count-lines 1 (1+ total)))
	 (line (save-restriction
		 (widen)
		 (save-excursion
		   (beginning-of-line)
		   (1+ (count-lines 1 (point)))))))
    
    (if (= pos end)
	;; if at end of (narrowed) buffer, cannot give info on Char,
	;; only on Point, Line and Column:
	(if (or (/= beg 1) (/= end (1+ total)))
	    ;; if narrowed, indicate narrowed region:
	    (message
	     "Point: %d/%d (%d%%) <%d - %d>  Line: %d/%d  Column %d/%d %s"
	     pos total percent beg end line total-lines col total-col hscroll)
	  (message
	   "Point: %d/%d (%d%%)  Line: %d/%d Column: %d/%d %s"
	   pos total percent line total-lines col total-col hscroll))
      ;; not at end, cursor is on some Char
      (if (or (/= beg 1) (/= end (1+ total)))
	  ;; buffer is narrowed, indicate narrowed region
	  (message
	   "Char: %s (0%o=%d=0x%x)  Point: %d/%d (%d%%) <%d - %d>  Line: %d/%d Column: %d/%d %s"
	   (single-key-description char) char char char pos total
	   percent beg end line total-lines col total-col hscroll)
	;; no narrowing in effect
	(message
	 "Char: %s (0%o=%d=0x%x)  Point: %d/%d (%d%%)  Line: %d/%d  Column: %d/%d %s"
	 (single-key-description char) char char char pos total percent
	 line total-lines col total-col hscroll)))))

------------------------------------------

-- 
/* Amir J. Katz  E-mail: amir@ndsoft.com   URL: http://www.ndsoft.com */
/* EagleEye Control Software, LTD., Tel-Aviv, Israel                  */
/* .. I busted a mirror and got seven years bad luck, but my        ..*/
/* .. lawyer thinks he can get me five.        (Steven Wright)      ..*/

