Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"Your butt is mine." -- Michael Jackson, Bad


computers / comp.os.vms / Emacs: Navigation By Sections

SubjectAuthor
o Emacs: Navigation By SectionsLawrence D'Oliveiro

1
Emacs: Navigation By Sections

<utlqgg$3fai5$2@dont-email.me>

  copy mid

https://news.novabbs.org/computers/article-flat.php?id=33778&group=comp.os.vms#33778

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.os.vms
Subject: Emacs: Navigation By Sections
Date: Sat, 23 Mar 2024 05:49:04 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <utlqgg$3fai5$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 23 Mar 2024 05:49:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="50afb5c9c454d4fc23edeea8f731b72c";
logging-data="3648069"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YrbKJKdQUN/8jzFWvvyVd"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:FMMML6wbT+zlvnAJbE6TkHe9vrI=
 by: Lawrence D'Oliv - Sat, 23 Mar 2024 05:49 UTC

Some of my earliest exposure to code written by others was on a DEC
PDP-11 system. So I somehow picked up the habit of writing
section-header comments that look like this:

;+
; Navigation by sections
;-

Of course, this can be adapted to other languages that use different
comment delimiters:

#+
# High-level stuff follows
#-

However, where the language allows block comments (like C), I still
have this fondness for using those instead:

/*
Binary heaps

See definition module for an explanation
*/

So I wrote a pair of simple navigation commands that will match
section-header comments written in all these different formats, and
lets me jump quickly between them:

(setq section-header-pattern "^\\(?:[\\#;]\\+\\|/\\*\\)$")
(setq section-header-end-pattern "^\\(?:[\\#;]-\\|\\*/\\)$")
; Allows for: “#+\n...#-\n” (Python etc); “;+\n...;-\n” (Lisp); “/*\n...*/\n” (C).

(defun prev-section ()
(interactive)
(beginning-of-line)
(unless (re-search-backward section-header-pattern nil t)
(goto-char (point-min))
) ; unless
) ; prev-section

(defun next-section ()
(interactive)
(end-of-line)
(cond
((re-search-forward section-header-pattern nil t)
(beginning-of-line)
)
(t
(goto-char (point-max))
)
) ; cond
) ; next-section

(global-set-key [kp-subtract] 'prev-section)
(global-set-key [kp-add] 'next-section)

Yeah, I bind them to the numeric-keypad “+” and “-” keys. Does anybody
use those for anything else? ;)

Do people writing code on DEC systems still use a convention like this?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor