Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] slight optimisation at client/packhand.c
Home

[Freeciv-Dev] Re: [PATCH] slight optimisation at client/packhand.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Trent Piepho <xyzzy@xxxxxxxxxxxxx>
Cc: Gaute B Strokkenes <gs234@xxxxxxxxx>, Markus Linnala <maage@xxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] slight optimisation at client/packhand.c
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 09:20:23 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Aug 15, 2001 at 07:18:35PM -0700, Trent Piepho wrote:
> On Thu, 16 Aug 2001, Gaute B Strokkenes wrote:
> > This needs more spaces.  Also, the && should be at the beginning of
> > the line, not the end.
> 
> Other people (like me) like && at the end better, and it's more common that
> way in the code.

I also like the && at the end and some other things. However you have
to follow the rules. This is easy if you use emacs and something like:

---
(defun indent-region-by-shell-command () "some docu"
  (interactive)

  (setq orig-point-pos (point))
  (setq my-start-marker (copy-marker (region-beginning)))
  (setq my-end-marker (copy-marker (region-end)))

  ; If the region ends on a newline this leaves a newline after
  ; indention.  Increase the end of region by one.

  (goto-char (marker-position my-end-marker))
  (if (eolp)
      (set-marker my-end-marker (+ 1 (marker-position my-end-marker)))
    ())

  (goto-char (marker-position my-start-marker))
  (beginning-of-line)
  (skip-chars-forward "\t ")

  (setq braces-needed (/ (current-column) 2))
  (beginning-of-line)
  (setq start-of-braces-pos (point))
  (setq num 0)
  (while (< num braces-needed)
    (insert "{")
    (setq num (1+ num)))
  (insert "\n")

  (shell-command-on-region
   start-of-braces-pos
   (marker-position my-end-marker)
   ; get rid of 'Unexpected end of file' message
   "indent -kr -i2 2>&1 | grep -v Unexpected" 1)

  (goto-char start-of-braces-pos)
  (while (not (eolp))
    (delete-char 1))
  (delete-char 1)
  (goto-char (marker-position my-start-marker))
  )

(global-set-key 'f2 'indent-region-by-shell-command)
---

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  A supercomputer is a computer running an endless loop in just a second


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