Explore a little untyped functional programming using elisp

Assignment Help Programming Languages
Reference no: EM131439718

PLC: Homework

The goal of this homework is to explore a little untyped functional programming using elisp, the version of the LISP programming language supported by the emacs text editor.

Basics of elisp programming

All coding in this assignment will be in elisp. emacs (and also the internet) provides quite a bit of good documentation about elisp. We will also be looking at this in class March 21 and 23. Some useful commands for basic elisp programming:

Control-h k tells you what elisp command is executed for the keystroke you enter right after typing Control-h k.

Control-h f gives you documentation about the elisp function you name.

Contrl-h v gives you documentation about an elisp variable you name.

Meta-: (type \meta", which is often bound to the \alt" key, or else the escape key always works for meta; and then type a colon): this lets you enter an elisp expression to be evaluated.

Control-Meta-x If your cursor is sitting in a function definition in a .el file (within emacs), then this will actually add that function definition to elisp, so you can then call it using Meta-:.

To define a new elisp function, the syntax is

(defun NAME(ARGS) DESCRIPTION CODE)

where NAME is the name of your function, ARGS is a list (separated just by spaces) of any input variables to the function, DESCRIPTION is a double-quoted string giving a description of the function, and CODE is then the code for the function.

2. Basic elisp programming

In a file called basic.el, write functions to do the following (of course you should test them in a sample buffer). I am giving some hints about how to do these tasks, by referencing existing elisp functions you can use. (These functions are already defined in elisp; use Control-h f, as described above, to learn more about these functions.)

1. goto-middle which should cause your cursor to jump to the middle character of the buffer. You can move the cursor using the function goto-char and you can find the beginning and ending characters of the buffer using (point-min) and (point-max) respectively.

2. switch-halves which should switch the first half of your buffer's text with the second half. You can use the function kill-region to cut a region of text, and yank to paste it back.

3. capother which should capitalize every other word in the buffer, starting from the beginning (point-min) to the end of the buffer (point-max). To capitalize a region of text, you can use upcase-region.

3. Extending an XML navigation mode

Thanks to some amazing software called se-mode (\structured editing mode") written by PLC alum Carl Olson, we can pretty easily turn emacs into an IDE for a language, if we have a backend parser for that language. For this problem, we will do this for basic XML. First, compile mainx.agda. This is the backend tool that will parse XML and send to the frontend (emacs mode) an abstract description of the parse tree. The se-mode code in the frontend will assemble a parse tree internally from that abstract description, and then provides commands for the user to navigate through the parse tree. To see what mainx is sending to the frontend, you can run mainx and just type in the name of a .xml file like AUFLIA.xml (provided with hw8). You will see a dump of a bunch of information.

For this problem, you will just be modifying xmlnav-mode.el. First, you need to configure emacs so it knows about this new mode. To do that, copy the se-mode directory and all its files into your hw8 directory. It is important that you have an se-mode directory as a subdirectory of your hw8 directory. Put xmlnav-mode.el and the mainx executable in your hw8 directory (not the se-mode subdirectory). Then open your .emacs file (type Control-x Control-f in emacs, and then type ~/.emacs). Add the following commands somewhere in the .emacs file (where PATH-TO-HW8-DIRECTORY should be the path on your computer to your hw8 directory) and then save it, and restart emacs: (add-to-list 'load-path "PATH-TO-HW8-DIRECTORY") (require 'xmlnav-mode)

Now open the file AUFLIA.xml, included with the hw8 files. If all goes well, you should be able to type \Meta-s" (alt-s or escape-s), and you should see \(xmlnav navi)" displayed in the mode line towards the bottom of your emacs window. You can then use \p", \n", \f", and \b" to navigate through the text following the structure of the parse tree.

3.1 Showing errors

Modify xmlnav-mode-update-mini in xmlnav-mode.el so that if the current selected parse-tree node has an error attribute, the error is shown as a message. To do this:

(se-mode-selected) will return the current selected node, if any.

se-term-data, given a node, will return the attributes associated (by the backend) with that data.

The assoc function will let you look for an 'error attribute in the attributes returned by se-term-data.

if there is an 'error attribute, you can use message to print out the data which is part of that attribute. The attribute is a pair that looks like 'error . m. To access the second component of a pair in elisp, you use the cdr function.

You should see an error at the very last end tag of AUFLIA.xml, which does not match the start tag.

3.2 Hiding elements

Modify xmlnav-mode-toggle-hidden so that it toggles whether the selected node (if there is one) is invisible or not. To get, set, or clear the invisibility property, respectively, you use get-text-property, put-text-property and remove-text-properties. There is good documentation about text properties here:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Text-Properties.html

If there is no 'invisible property for the currently selected node, you should set the 'invisible to 'xmlnav-hide. I have already added code in xmlnav-mode.el to tell emacs to display invisible text with an ellipsis (...) if the 'invisible property is set to 'xmlnav-hide. If there is a 'invisible property for the currently selected node, you should remove it with remove-text-properties.

After this is done, call se-navigation-mode 1 to restart the navi mode (which shuts o
automatically if the buffer is modified), and also call se-mode-select with the node that was selected at the start of the call to xmlnav-mode-toggle-hidden, so it will be reselected.

Attachment:- Assignment.zip

Reference no: EM131439718

Questions Cloud

Analyze the legal and ethical and community standards : Analyze the legal, ethical, and community standards within the mental health and wellness field.Propose strategies to promote self-care and wellbeing for mental health and wellness providers.
What is your preferred use of the two fiscal tools : What is your preferred use of the two fiscal tools (four options) to resolve gaps? In your opinion who should receive the benefit or bear the cost of your fiscal tool(s)? Be specific.
Do you agree or disagree with this reasoning : "Cultures around the world are becoming increasingly similar, so companies should standardize both their products and global marketing efforts." Do you agree or disagree with this reasoning? Are there certain industries for which it might be more ..
What is cloud computing : What is cloud computing? Define what the cloud consists of, in terms of infrastructure. Why do you consider that cloud computing and mobile devices are “partner technologies” that work together well?
Explore a little untyped functional programming using elisp : The goal of this homework is to explore a little untyped functional programming using elisp, the version of the LISP programming language supported by the emacs text editor
Statements is best about sales and operations planning : For the last week a work center had a planned input of 40 standard hours and an actual input of 36 standard hours. The planned output was 40, the actual output 42 standard hours and the beginning backlog was 30 hours. The cumulative input variance wa..
Determine the status of the design relative to the cost goal : In this Fiscussion a cost analysis is performed to determine the status of the design relative to the cost goals. Discuss the alternatives that can be considered if the detailed design is already over the identified cost goal.
Identify the decision variables in simple verbal statements : A business student has $2,500 available from a summer job and has identified three potential stocks in which to invest. The cost per share and expected return over the next 2 years is given in the table.
Describe the legal and ethical issues surrounding physician : Describe some of the legal and ethical issues surrounding physician-assisted suicides. What implications does it have on health services managers and health economics as a whole?The topic of the research paper will be any disease or condition of th..

Reviews

len1439718

3/25/2017 1:51:34 AM

The goal of this homework is to explore a little untyped functional programming using elisp, the version of the LISP programming language supported by the emacs text editor. As usual, the first thing you should do for this homework is copy the files from the hw/hw8 subdirectory of the class repository, to a new hw8 subdirectory of your personal repository, similarly to previous homeworks. For this homework, you may work by yourself or with one partner (no more). See the instructions for hw2 for how to create the ack.txt and partner.txt files that are required if you work with a partner. You can post questions in the hw8 section on Piazza, or elsewhere on Piazza. See the course's Google Calendar, linked from Piazza, for the locations and times for office hours, including evening Skype office hours for Prof. Stump.

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd