Revert "emerge: Implement "--alert""

This reverts commit 1a00ddf5fb089724a127c8dc72d63f10ae72abbf. It had
some furiously annoying mistakes in the commit message. Also, someone
alluded to the man page being too short. Thanks, Brian.

Signed-off-by: Alexander Berntsen <bernalex@gentoo.org>
diff --git a/man/emerge.1 b/man/emerge.1
index bbcf569..abb0ed8 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -297,11 +297,6 @@
 configuration, this would result in an effective
 \fBACCEPT_RESTRICT\fR value of "* -bindist".
 .TP
-.BR "\-\-alert "
-Add a terminal bell character ('\\a') to all interactive prompts. This is
-especially useful if dependency resolution is taking a long time, and
-you want emerge to alert you when it is finished.
-.TP
 .BR "\-\-alphabetical "
 When displaying USE and other flag output, combines the enabled and
 disabled lists into one list and sorts the whole list alphabetically.
diff --git a/pym/_emerge/UserQuery.py b/pym/_emerge/UserQuery.py
deleted file mode 100644
index c866a0d..0000000
--- a/pym/_emerge/UserQuery.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-from __future__ import print_function
-
-import signal
-import sys
-
-from portage.output import bold, create_color_func
-
-
-class UserQuery(object):
-	"""The UserQuery class is used to prompt the user with a set of responses,
-	as well as accepting and handling the responses."""
-
-	def __init__(self, myopts):
-		self.myopts = myopts
-
-	def query(self, prompt, enter_invalid, responses=None, colours=None):
-		"""Display a prompt and a set of responses, then waits for user input
-		and check it against the responses. The first match is returned.
-
-		An empty response will match the first value in the list of responses,
-		unless enter_invalid is True. The input buffer is *not* cleared prior
-		to the prompt!
-
-		prompt: The String to display as a prompt.
-		responses: a List of Strings with the acceptable responses.
-		colours: a List of Functions taking and returning a String, used to
-		process the responses for display. Typically these will be functions
-		like red() but could be e.g. lambda x: "DisplayString".
-
-		If responses is omitted, it defaults to ["Yes", "No"], [green, red].
-		If only colours is omitted, it defaults to [bold, ...].
-
-		Returns a member of the List responses. (If called without optional
-		arguments, it returns "Yes" or "No".)
-
-		KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
-		printed."""
-		if responses is None:
-			responses = ["Yes", "No"]
-			colours = [
-				create_color_func("PROMPT_CHOICE_DEFAULT"),
-				create_color_func("PROMPT_CHOICE_OTHER")
-			]
-		elif colours is None:
-			colours=[bold]
-		colours=(colours*len(responses))[:len(responses)]
-		if "--alert" in self.myopts:
-			prompt = '\a' + prompt
-		print(bold(prompt), end=' ')
-		try:
-			while True:
-				if sys.hexversion >= 0x3000000:
-					response=input("["+"/".join([colours[i](responses[i])
-								  for i in range(len(responses))])+"] ")
-				else:
-					response=raw_input("["+"/".join([colours[i](responses[i])
-									  for i in range(len(responses))])+"] ")
-				if response or not enter_invalid:
-					for key in responses:
-						# An empty response will match the
-						# first value in responses.
-						if response.upper()==key[:len(response)].upper():
-							return key
-				print("Sorry, response '%s' not understood." % response,
-		  end=' ')
-		except (EOFError, KeyboardInterrupt):
-			print("Interrupted.")
-			sys.exit(128 + signal.SIGINT)
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index b935139..4ca2f1c 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -84,7 +84,7 @@
 from _emerge.unmerge import unmerge
 from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
-from _emerge.UserQuery import UserQuery
+from _emerge.userquery import userquery
 
 if sys.hexversion >= 0x3000000:
 	long = int
@@ -387,9 +387,8 @@
 			else:
 				prompt="Would you like to merge these packages?"
 		print()
-		uq = UserQuery(myopts)
 		if prompt is not None and "--ask" in myopts and \
-			uq.query(prompt, enter_invalid) == "No":
+			userquery(prompt, enter_invalid) == "No":
 			print()
 			print("Quitting.")
 			print()
@@ -469,7 +468,6 @@
 
 def action_config(settings, trees, myopts, myfiles):
 	enter_invalid = '--ask-enter-invalid' in myopts
-	uq = UserQuery(myopts)
 	if len(myfiles) != 1:
 		print(red("!!! config can only take a single package atom at this time\n"))
 		sys.exit(1)
@@ -499,7 +497,7 @@
 				print(options[-1]+") "+pkg)
 			print("X) Cancel")
 			options.append("X")
-			idx = uq.query("Selection?", enter_invalid, responses=options)
+			idx = userquery("Selection?", enter_invalid, responses=options)
 			if idx == "X":
 				sys.exit(128 + signal.SIGINT)
 			pkg = pkgs[int(idx)-1]
@@ -514,7 +512,7 @@
 
 	print()
 	if "--ask" in myopts:
-		if uq.query("Ready to configure %s?" % pkg, enter_invalid) == "No":
+		if userquery("Ready to configure %s?" % pkg, enter_invalid) == "No":
 			sys.exit(128 + signal.SIGINT)
 	else:
 		print("Configuring pkg...")
@@ -1366,8 +1364,7 @@
 			if '--ask' in opts:
 				prompt = "Would you like to remove these " + \
 					"packages from your world favorites?"
-				uq = UserQuery(opts)
-				if uq.query(prompt, enter_invalid) == 'No':
+				if userquery(prompt, enter_invalid) == 'No':
 					return 128 + signal.SIGINT
 
 			remaining = set(world_set)
@@ -2405,8 +2402,7 @@
 
 			if (retries==0):
 				if "--ask" in myopts:
-					uq = UserQuery(myopts)
-					if uq.query("Do you want to sync your Portage tree " + \
+					if userquery("Do you want to sync your Portage tree " + \
 						"with the mirror at\n" + blue(dosyncuri) + bold("?"),
 						enter_invalid) == "No":
 						print()
@@ -3845,8 +3841,7 @@
 						(access_desc,), noiselevel=-1)
 					if portage.data.secpass < 1 and not need_superuser:
 						portage.data.portage_group_warning()
-					uq = UserQuery(emerge_config.opts)
-					if uq.query("Would you like to add --pretend to options?",
+					if userquery("Would you like to add --pretend to options?",
 						"--ask-enter-invalid" in emerge_config.opts) == "No":
 						return 128 + signal.SIGINT
 					emerge_config.opts["--pretend"] = True
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 8177b74..bede7c6 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -73,7 +73,7 @@
 from _emerge.show_invalid_depstring_notice import show_invalid_depstring_notice
 from _emerge.UnmergeDepPriority import UnmergeDepPriority
 from _emerge.UseFlagDisplay import pkg_use_display
-from _emerge.UserQuery import UserQuery
+from _emerge.userquery import userquery
 
 from _emerge.resolver.backtracking import Backtracker, BacktrackParameter
 from _emerge.resolver.package_tracker import PackageTracker, PackageTrackerDbapiWrapper
@@ -520,9 +520,6 @@
 		self._event_loop = (portage._internal_caller and
 			global_event_loop() or EventLoop(main=False))
 
-		self.uq = UserQuery(myopts)
-		self.query = UserQuery.query
-
 	def _load_vdb(self):
 		"""
 		Load installed package metadata if appropriate. This used to be called
@@ -7658,7 +7655,7 @@
 		if ask and write_to_file and file_to_write_to:
 			prompt = "\nWould you like to add these " + \
 				"changes to your config files?"
-			if self.query(prompt, enter_invalid) == 'No':
+			if userquery(prompt, enter_invalid) == 'No':
 				write_to_file = False
 
 		if write_to_file and file_to_write_to:
@@ -7925,7 +7922,7 @@
 					"favorites?"
 				enter_invalid = '--ask-enter-invalid' in \
 					self._frozen_config.myopts
-				if self.query(prompt, enter_invalid) == "No":
+				if userquery(prompt, enter_invalid) == "No":
 					skip = True
 
 			if not skip:
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 1a920f7..eddb16c 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -124,7 +124,6 @@
 	new_args = []
 
 	default_arg_opts = {
-		'--alert'                : y_or_n,
 		'--ask'                  : y_or_n,
 		'--autounmask'           : y_or_n,
 		'--autounmask-keep-masks': y_or_n,
@@ -170,7 +169,6 @@
 	# since existence of -n makes it too ambiguous.
 	short_arg_opts_n = {
 		'a' : y_or_n,
-		'A' : y_or_n,
 		'b' : y_or_n,
 		'g' : y_or_n,
 		'G' : y_or_n,
@@ -302,12 +300,6 @@
 	true_y = ("True", "y")
 	argument_options = {
 
-		"--alert": {
-			"shortopt" : "-A",
-			"help"    : "alert (terminal bell) on prompts",
-			"choices" : true_y_or_n
-		},
-
 		"--ask": {
 			"shortopt" : "-a",
 			"help"    : "prompt before performing any actions",
@@ -683,11 +675,6 @@
 
 	myoptions, myargs = parser.parse_known_args(args=tmpcmdline)
 
-	if myoptions.alert in true_y:
-		myoptions.alert = True
-	else:
-		myoptions.alert = None
-
 	if myoptions.ask in true_y:
 		myoptions.ask = True
 	else:
diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py
index 8f98563..b04f8f3 100644
--- a/pym/_emerge/unmerge.py
+++ b/pym/_emerge/unmerge.py
@@ -17,8 +17,8 @@
 
 from _emerge.emergelog import emergelog
 from _emerge.Package import Package
-from _emerge.UserQuery import UserQuery
 from _emerge.UninstallFailure import UninstallFailure
+from _emerge.userquery import userquery
 from _emerge.countdown import countdown
 
 def _unmerge_display(root_config, myopts, unmerge_action,
@@ -529,8 +529,7 @@
 		#we're done... return
 		return os.EX_OK
 	if "--ask" in myopts:
-		uq = UserQuery(myopts)
-		if uq.query("Would you like to unmerge these packages?",
+		if userquery("Would you like to unmerge these packages?",
 			enter_invalid) == "No":
 			# enter pretend mode for correct formatting of results
 			myopts["--pretend"] = True
diff --git a/pym/_emerge/userquery.py b/pym/_emerge/userquery.py
new file mode 100644
index 0000000..efae80a
--- /dev/null
+++ b/pym/_emerge/userquery.py
@@ -0,0 +1,55 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from __future__ import print_function
+
+import signal
+import sys
+
+from portage.output import bold, create_color_func
+
+def userquery(prompt, enter_invalid, responses=None, colours=None):
+	"""Displays a prompt and a set of responses, then waits for a response
+	which is checked against the responses and the first to match is
+	returned. An empty response will match the first value in responses,
+	unless enter_invalid is True. The input buffer is *not* cleared prior
+	to the prompt!
+
+	prompt: a String.
+	responses: a List of Strings.
+	colours: a List of Functions taking and returning a String, used to
+	process the responses for display. Typically these will be functions
+	like red() but could be e.g. lambda x: "DisplayString".
+	If responses is omitted, defaults to ["Yes", "No"], [green, red].
+	If only colours is omitted, defaults to [bold, ...].
+
+	Returns a member of the List responses. (If called without optional
+	arguments, returns "Yes" or "No".)
+	KeyboardInterrupt is converted to SystemExit to avoid tracebacks being
+	printed."""
+	if responses is None:
+		responses = ["Yes", "No"]
+		colours = [
+			create_color_func("PROMPT_CHOICE_DEFAULT"),
+			create_color_func("PROMPT_CHOICE_OTHER")
+		]
+	elif colours is None:
+		colours=[bold]
+	colours=(colours*len(responses))[:len(responses)]
+	print(bold(prompt), end=' ')
+	try:
+		while True:
+			if sys.hexversion >= 0x3000000:
+				response=input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
+			else:
+				response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ")
+			if response or not enter_invalid:
+				for key in responses:
+					# An empty response will match the
+					# first value in responses.
+					if response.upper()==key[:len(response)].upper():
+						return key
+			print("Sorry, response '%s' not understood." % response, end=' ')
+	except (EOFError, KeyboardInterrupt):
+		print("Interrupted.")
+		sys.exit(128 + signal.SIGINT)