GNU bug report logs - #8386
[patch] capitalization bug in NATO

Previous Next

Package: emacs;

Reported by: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>

Date: Thu, 31 Mar 2011 04:48:02 UTC

Severity: minor

Tags: patch

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8386 in the body.
You can then email your comments to 8386 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8386; Package emacs. (Thu, 31 Mar 2011 04:48:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 31 Mar 2011 04:48:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Glenn Morris <rgm <at> gnu.org>
Subject: [patch] capitalization bug in NATO
Date: Thu, 31 Mar 2011 00:46:57 -0400
[Message part 1 (text/plain, inline)]
Follow-up to my initial contribution of NATO alphabetization in #2288,
I noticed that `denato-region' will not always work because `rassoc'
is being case-sensitive.

I've provided a command to operate on strings as a test suite, where

(nato-string "echo mike alfa charlie sierra" t)

should give "emacs", but it does not.

The following will work since the capitalization jives with internals.

(nato-string "Echo Mike Alfa Charlie Sierra" t)

Attached is a proposed patch.

Thanks.
/a

2011-03-31  Aaron S. Hawley  <aaron.s.hawley <at> gmail.com>

	* play/morse.el (denato-region): Decoding NATO alphabet encodings
	should be done case-insensitive.
	(nato-string): New function.

--- lisp/play/morse.el	2011-03-07 07:35:25 +0000
+++ lisp/play/morse.el	2011-03-31 04:25:45 +0000
@@ -231,7 +231,7 @@
 	(if (null (looking-at "[a-z]+"))
 	    (forward-char 1)
 	  (setq str (buffer-substring (match-beginning 0) (match-end 0)))
-	  (if (null (setq nato (rassoc str nato-alphabet)))
+	  (if (null (setq nato (rassoc (capitalize str) nato-alphabet)))
 	      (goto-char (match-end 0))
 	    (replace-match
 		  (if (string-equal "(" (car nato))
@@ -240,6 +240,18 @@
 	    (if (looking-at "-")
 		(delete-char 1))))))))

+(defun nato-string (string &optional arg)
+  "Convert NATO phonetic alphabet in STRING to ordinary ASCII text."
+  (interactive "sConvert to NATO: \nP")
+  (with-temp-buffer
+    (insert string)
+    (if arg
+        (denato-region (point-min) (point-max))
+      (nato-region (point-min) (point-max)))
+    (if (interactive-p)
+        (message (buffer-string))
+      (buffer-string))))
+
 (provide 'morse)

 ;;; morse.el ends here

-- 
In general, we reserve the right to have a poor
memory--the computer, however, is supposed to
remember!  Poor computer.  -- Guy Lewis Steele Jr.
[morse.el.diff (application/octet-stream, attachment)]

Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Thu, 07 Apr 2011 03:27:01 GMT) Full text and rfc822 format available.

Notification sent to "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>:
bug acknowledged by developer. (Thu, 07 Apr 2011 03:27:02 GMT) Full text and rfc822 format available.

Message #10 received at 8386-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 8386-done <at> debbugs.gnu.org
Subject: Re: [patch] capitalization bug in NATO
Date: Wed, 06 Apr 2011 23:26:29 -0400
(no need to cc me on reports)

"Aaron S. Hawley" wrote:

> -	  (if (null (setq nato (rassoc str nato-alphabet)))
> +	  (if (null (setq nato (rassoc (capitalize str) nato-alphabet)))

Applied.

> +(defun nato-string (string &optional arg)

I don't see a need for this command.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 05 May 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 54 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.