lisp

In Elisp, how to get path string with slash properly inserted?

*爱你&永不变心* 提交于 2019-11-30 13:08:35
I am manually constructing path strings in Elisp by concatenating partial paths and directory names. Unfortunately sometimes the paths end with slash, sometimes not. Therefore, I need to insert slash before concatenating a directory name when necessary but not otherwise. What's a good way to do this? (file-name-as-directory dir) will return directory path dir with a trailing slash, adding one if necessary, and not otherwise. If you had your sequence of partial paths in a list, you could do something like: (let ((directory-list '("/foo" "bar/" "p/q/" "x/y")) (file-name "some_file.el")) (concat

How to change emacs config in Lisp In A Box

北慕城南 提交于 2019-11-30 13:07:42
I have been a programmer for a decade now, but I believe this is the first time I've ever asked a question on a forum. I just can't figure this out and can't find the answer already online. I am trying to turn on CUA mode so that emacs is more bearable for a windows user (normal copy paste functions). I am running Windows 7 and installed emacs through the Lisp In A Box package. I understand that I need to add a line to my .emacs file or init.el file. I'm not sure which, but I can't find either in my Lip In A Box install directory. The emacs package install also did not come with any tutorials

How is the `*var-name*` naming-convention used in clojure?

倖福魔咒の 提交于 2019-11-30 12:59:47
问题 As a non-lisper coming to clojure how should I best understand the naming convention where vars get a name like *var-name* ? This appears to be a lisp convention indicating a global variable. But in clojure such vars appear in namespaces as far as I can tell. I would really appreciate a brief explanation of what I should expect when an author has used such vars in their code, ideally with a example of how and why such a var would be used and changed in a clojure library. 回答1: It's a

Maximizing / restoring a window in emacs

时光毁灭记忆、已成空白 提交于 2019-11-30 12:49:30
问题 Ok, so maybe this is more a question for the superuser site but I figured there'd be a hell of a lot more emacs users on stackoverflow. Basically I often have my emacs split into about 4 windows so I can look at a bunch of buffers at the same time.. however I'd like to be able to C-x 1 (make the window the same size as emacs) and then somehow restore back to my nice 4 window layout I was just looking at. Is there an easy way to do this or do I need some elisp / lisp (note: I don't know ANY

Using Lisp in C#

懵懂的女人 提交于 2019-11-30 12:45:41
As a lot of people pointed out in this question , Lisp is mostly used as a learning experience. Nevertheless, it would be great if I could somehow use my Lisp algorithms and combine them with my C# programs. In college my profs never could tell me how to use my Lisp routines in a program (no, not writing a GUI in Lisp, thank you). So how can I? jfs Try these .Net implementations of Lisp: IronScheme IronScheme will aim to be a R6RS conforming Scheme implementation based on the Microsoft DLR. L Sharp .NET L Sharp .NET is a powerful Lisp-like scripting language for .NET. It uses a Lisp dialect

mcons in dr racket

喜夏-厌秋 提交于 2019-11-30 12:44:47
I'm having trouble reading output from dr racket. By default it displays lists using mcons. For example, sicp exercise 2.32 produces: > (subsets (list 1 2 3)) (mcons (mcons '() (mcons (mcons 3 '()) (mcons (mcons 2 '()) (mcons (mcons 2 (mcons 3 '())) (mcons (mcons 1 '()) (mcons (mcons 1 (mcons 3 '())) (mcons (mcons 1 (mcons 2 '())) (mcons (mcons 1 (mcons 2 (mcons 3 '()))) '())))))))) '()) I'm having trouble reading this. Is there a way to make the output look like: (() (3) (2) (2 3) (1) (1 3) (1 2) (1 2 3)) Thanks! Do you know what language are you using in your #lang line? The rest of the

Can you execute multiple statements in an “if” statement?

有些话、适合烂在心里 提交于 2019-11-30 12:33:43
问题 This is my function: (defun MyFunction(input) (let ((NEWNUM (find input num))) (if (find input num) //if this (setq num NEWNUM) (FUNCT2) //then execute both of these (list 'not found)))) //else output this So after the if statement I want to be able to execute (setq num NEWNUM) followed by (FUNCT2) in order to set a new variable and then call a function. Any ideas on how to do this? 回答1: To do several things in sequence, you want progn . (defun MyFunction(input) (let ((NEWNUM (find input num)

What does (interactive) mean in an Emacs Lisp function?

帅比萌擦擦* 提交于 2019-11-30 12:33:36
问题 Emacs Lisp function often start like this: (lambda () (interactive) ... What does "(interactive)" do? 回答1: Just to clarify (it is in the quoted docs that Charlie cites) (interactive) is not just for key-bound functions, but for any function. Without (interactive) , it can only be called programmatically, not from M-x (or via key-binding). EDIT: Note that just adding "(interactive)" to a function won't necessarily make it work that way, either -- there could be many reasons functions are not

How do I take a slice of a list (A sublist) in scheme?

老子叫甜甜 提交于 2019-11-30 11:35:56
Given a list, how would I select a new list, containing a slice of the original list (Given offset and number of elements) ? EDIT: Good suggestions so far. Isn't there something specified in one of the SRFI's? This appears to be a very fundamental thing, so I'm surprised that I need to implement it in user-land. The following code will do what you want: (define get-n-items (lambda (lst num) (if (> num 0) (cons (car lst) (get-n-items (cdr lst) (- num 1))) '()))) ;' (define slice (lambda (lst start count) (if (> start 1) (slice (cdr lst) (- start 1) count) (get-n-items lst count)))) Example: >

emacs setup for both clojure and common lisp with slime-fancy (slime-autodoc)

亡梦爱人 提交于 2019-11-30 11:08:59
问题 I set up emacs for both clojure and common lisp, but I want also (slime-setup '(slime-fancy)) for common lisp. If I add that line to init.el, clojure won't work: it gives me repl, but it hangs after I run any code. My configuration For clojure: I set up clojure-mode, slime, slime-repl via ELPA I run $ lein swank in project directory Then M-x slime-connect to hack clojure For common lisp I place this after ELPA code in init.el: (add-to-list 'load-path "~/.elisp/slime") (require 'slime) (add-to