emacs 24.2 tab-width always set to 2 - emacs24

I've been trying to get to work my tab-width variable, but apparently I can't with my configuration. It supposed to be working with the first two lines but nothing. And the problem is that I always get 2 spaces for indentation and never 4. I copy the important part of the code.
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
(mapc (lambda (hook)
(add-hook hook (lambda ()
(setq-default tab-width 4))))
'(js2-mode-hook
js-mode-hook
css-mode-hook
less-css-mode-hook
php-mode-hook
html-mode-hook
))
I've been trying to modify a little bit the configuration, but there is not a lot to do about it.

I forgot to answer to my own question when I solved my problem (it was a while ago). The next is the part of my code in my emacs initialization file. I had to configure manually some emacs-modes, but it's working.
;; indentiation stuff (maybe some variable is missing for other language
(setq-default indent-line-function 4)
(setq-default tab-width 4)
(setq-default c-basic-offset 4)
(setq-default lisp-indent-offset 4)
(setq-default sgml-basic-offset 4)
(setq-default nxml-child-indent 4)
(setq tab-stop-list (number-sequence 4 200 4))
I hope it solves somebody's problem too.

Related

Emacs ESS error ess-toggle-S-assign wrong number of arguments

After installing Emacs and Emacs Speaks Statistics (ESS) on a new machine, I am receiving the following error when I open an R buffer: ess-toggle-S-assign wrong number of arguments. I believe that this occurs due to the following section in my .emacs file where I reassign the assignment key from _ to ;, as shown below. Why does my .emacs file no longer work?
;; ESS hook additions. Note that the duplicate calls to `(ess-toggle-S-assign
;; nil)` are correct: the first call clears the default `ess-smart-S-assign`
;; assignment and the second line re-assigns it to the customized setting.
(add-hook 'ess-mode-hook
(lambda ()
(setq ess-smart-S-assign-key ";") ; reassign ' <- ' to ';'
(ess-toggle-S-assign nil) ; see above comment
(ess-toggle-S-assign nil))) ; see above comment
According to the ESS documentation https://ess.r-project.org/Manual/ess.html#New-features
Customization of ess-smart-S-assign-key has been reworked. You should now set the value before ESS is loaded.
So to reassign the assignment key as before, simply remove the existing lines of code from the ESS mode hook, and instead include the following lines in your .emacs file.
(setq ess-smart-S-assign-key ";")
(require 'ess-site)

Concrete Syntax Matching in Rascal

If I have:
import demo::lang::Exp::Concrete::WithLayout::Syntax;
if ((Exp)`<IntegerLiteral e> + <IntegerLiteral e>` := (Exp)`5 + 6`) {
println(e);
}
This prints 6. Is this a possible bug or a design decision, e.g. because of performance considerations? It should of course not print anything, since e cannot be matched to both 5 and 6. This is, however, in contrast to matching with ADTs, where this is caught, i.e.:
data ExpNum = numb(int n) | add(ExpNum e1, ExpNum e2);
if (add(numb(x), numb(x)) := add(numb(5), numb(6))) { println(x); }
Will not print a number, while it does print a number when using numb(5) instead of numb(6).
Ps. I ran the example both from Rascal source using Eclipse Plug-in Development (using a forked version merged with the latest version of Rascal), as well as on two machines using the official Eclipse plugin. The plugin, however, returned the following on both machines:
|stdin:///|(4,46,<1,4>,<1,50>): Java compilation failed due to with classpath [/home/wouter/eclipse//plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar]: package org.eclipse.imp.pdb.facts.type does not exist
The reason why I am asking is because, somewhat similarly, ConcreteListVariablePattern automatically throws a RedeclaredVariable-exception without checking if the match result's value is equivalent to the variable in the environment, in contrast to e.g. QualifiedNamePattern which checks if the result is equivalent to the value in the environment in case of a readily declared variable.
Thank you!
This is definitely a bug: the variable e is declared twice (without warning), the match succeeds and the binding to second e is printed.
Expected behavior would be that a RedeclaredVariable exception is thrown.
A work around is as follows:
if ((Exp)`<IntegerLiteral e1> + <IntegerLiteral e2>` := (Exp)`5 + 6` && e1 == e2) {
println(e1);
}

Emacs css-mode not loading

I'm not sure why, but on my Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.4) css-mode is not loading and with M-x css-mode gives this error in Messages:
Symbol's function definition is void: apropos-macrop
or
File mode specification error: (void-function apropos-macrop)
my css file (ending in .css) is in Fundamental. I just tried it on a 23.1.1 and CSS mode comes up and works fine.
Update: Traced problem to my autoloads. i.e., comment out autoloads
;(load "~/modes/autoloads" 'install)
and the problem goes away. I'm not sure what to hack with an autoloads file. Any way to "step" through an autoloads? Here's my autoloads: http://gmcongo.org/temp/autoloads
In Emacs 24.4 and the bleeding edge versions leading to it (like 24.3.50+), apropos-macrop has been replaced by macrop. In css-mode.el, replace the call to apropos-macrop with a call to macrop and the error goes away.
Building upon the existing correct answer, you can create an alias in your ~/.emacs instead of editing css-mode (if for example, it came in a package with your distribution):
;; For css-mode, temporarily.
(defalias 'apropos-macrop 'macrop)

Orbeon 4.3 and localistion

I am trying to create an additional language entry for orbeon 4.3pe following this guide:
http://wiki.orbeon.com/forms/doc/contributor-guide/localizing-orbeon-forms
I did this couple of times for older versions of Orbeon (4.2 and 4.0) and it always worked that way.
The moment I remove the app/fr/i18n directory the application starts to work again.
When I start the application I get this error:
Toggle org.orbeon.saxon.trans.XPathException
Exception Class org.orbeon.saxon.trans.XPathException
Message An empty sequence is not allowed as the first argument of xxf:format-message()
The error seems to come from oxf:/apps/fr/components/components.xsl
The additional information:
element →
evaluating XPath expression
expression → xxf:format-message( $fr-resources/errors/form-title, ( xxf:instance('fr-error-summary-instance')/visible-counts/(if (count((#error, #warning, #info)[. gt 0]) gt 1) then 3 else if (#error gt 0) then 0 else if (#warning gt 0) then 1 else if (#info gt 0) then 2 else 4), xxf:instance('fr-error-summary-instance')/visible-counts/xs:integer(#alert), $title ) )
The most likely scenario is that you are providing a resources.xml file which does not match the one that ships with that specific Orbeon Forms version. Try this:
extract resources.xml from orbeon-form-runner-jar, or check this version on github for 4.3
in that file, compare the English section with your language section, and see if resources entries are not matching

URL-decode a string in Common Lisp

I have a string that contains an escaped URL:
http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz
I'm trying to decode it to the following:
http://example.com?foo=bar+baz
However, I can't find any suitable function exported by Drakma. I can encode like so:
* url-string
"http://example.com?foo=bar+baz"
* (drakma:url-encode url-string :utf-8)
"http%3A%2F%2Fexample.com%3Ffoo%3Dbar%2Bbaz"
... so I figure I'm on the right track. If anyone could supply a nudge in the right direction I'd appreciate it :-) I'm using SBCL 1.0.54, built from source on 64-bit Linux Mint 13.
If it helps clarify what I'm trying to do, in Ruby, I'd do the following:
> uri_string = "http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz"
=> "http%3A%2F%2Fexample.com%3Ffoo%3Dbar+baz"
> URI.decode uri_string
=> "http://example.com?foo=bar+baz"
A quick SLIME session.
CL-USER> (ql-dist:system-apropos "url")
#<SYSTEM curly / curly-20120407-git / quicklisp 2012-05-20>
#<SYSTEM curly.test / curly-20120407-git / quicklisp 2012-05-20>
#<SYSTEM do-urlencode / do-urlencode-20120407-git / quicklisp 2012-05-20>
#<SYSTEM url-rewrite / url-rewrite-0.1.1 / quicklisp 2012-05-20>
CL-USER> (ql:quickload :do-urlencode)
C-cC-dpdo-urlencodeRET
DO-URLENCODE:URLDECODE
Function: (not documented)
DO-URLENCODE:URLENCODE
Function: (not documented)
DO-URLENCODE:URLENCODE-MALFORMED-STRING
Type: (not documented)
DO-URLENCODE:URLENCODE-MALFORMED-STRING-STRING
Generic Function: (not documented)
CL-USER> (do-urlencode:urldecode "http%3A%2F%2Fexample.com%3Ffoo%3Dbar%2Bbaz")
"http://example.com?foo=bar+baz"
Found another solution, with Quri, a uri handling library with encoding and decoding utilities (for uri and parameters):
(url-decode "http%3A%2F%2Fexample.com%3Ffoo%3Dbar%2Bbaz")
;; "http://example.com?foo=bar+baz"
To install with (ql:quickload :quri) and then optionaly (use-package :quri).
(my sources: lisp-lang.org's recommend libraries and awesone-cl).

Resources